Page MenuHomePhabricator

Some suggestions for "bash-completion.sh"
AbandonedPublic

Authored by epriestley on Apr 8 2020, 1:11 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 14 2024, 6:09 PM
Unknown Object (File)
Feb 22 2024, 10:09 AM
Unknown Object (File)
Feb 16 2024, 8:37 AM
Unknown Object (File)
Jan 19 2024, 7:58 AM
Unknown Object (File)
Jan 15 2024, 11:22 PM
Unknown Object (File)
Nov 30 2023, 4:47 AM
Unknown Object (File)
Nov 17 2023, 4:11 PM
Unknown Object (File)
Oct 31 2023, 1:44 AM
Subscribers

Details

Summary

I got a fresh clone of "arcanist" from GitHub and noticed that the location of the bash-completion script moved. I updated my shell rc file to point to the new path, but ran into another problem: the script checks for the presence of the file using one path but sources a different path.

In addition to that, I think it would be useful to display an error if the generation process fails. That way the user does something about it instead of just adding 50ms to their shell startup every time.

I'm also displaying a message when generating, which should only happen once. Might help debug issues where the thing is broken. But this might be too noisy for some people's tastes.

Test Plan

N/A

Diff Detail

Repository
rARC Arcanist
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

epriestley added a reviewer: cakoose.

I updated my shell rc file to point to the new path

(You should be able to run arc shell-complete to do this automatically now.)

the script checks for the presence of the file using one path but sources a different path.

Yikes, thanks! I've adopted your change verbatim in D21085.

I think it would be useful to display an error if the generation process fails.

In most cases, we could remove the >dev/null 2>/dev/null to get status and error messages. They're currently fairly verbose. One advantage is that this will translate properly and can more easily give users detailed diagnostic information (like "no permission to write file"). A disadvantage is that errors like "arc not in path" won't have much context.

A possible alternate behavior that avoids putting English-language strings in a bash file is something like:

if [ ! -f "${GENERATED_RULES_FILE}" ]; then
  arc shell-complete --generate >/dev/null 2>/dev/null
  if [ ! -f "${GENERATED_RULES_FILE}" ]; then
    arc shell-complete --generate
  fi
fi

Since this feels like a tradeoff-balancing issue I'm inclined to not adopt any change for now and wait until there's a clearer picture of what issues actually arise here.

(Translating arc is possibly sort of not-really-a-goal since it's not realistic to accomplish most command-line or programming tasks without at least some knowledge of English, but I'd also philosophically prefer to minimize the amount of support/wrapper code in the codebase even if it isn't in service of a well-defined goal.)

SGTM!

I think it would be useful to display an error if the generation process fails.

In most cases, we could remove the >dev/null 2>/dev/null to get status and error messages. They're currently fairly verbose. One advantage is that this will translate properly and can more easily give users detailed diagnostic information (like "no permission to write file"). A disadvantage is that errors like "arc not in path" won't have much context.

Yeah, maybe arc shell-complete can take a --quiet flag that causes it to print nothing on success?