Skip to content

Diversity in Command Line Syntax

andychu edited this page Oct 18, 2018 · 13 revisions

bash itself has two options parsers

The long options have to appear BEFORE the short options.

Usage:  bash [GNU long option] [option] ...

bash --posix -x --<TAB> -- This should not complete any long options!

python

python -c -s <TAB> --

python -c x -s <TAB> --

-s is not a flag; it's an argument, because -c terminates flag parsing.

zsh seems to get this right; bash doesn't complete flags.

set builtin

set +oeu pipefail is equivalent to

set +o pipefail +e +u (try it in bash)

When I type, set +oeu , is the declarative way going to know that I should complete pipefail and not an arg?

I'm picking one of the worst cases, but my point is not that we have to handle them. My point is that the shared grammar shouldn't prevent you from handling these cases.

find command

find . -type f -<TAB> -- what is valid in that case? How do you write a grammar for it?

echo builtin

It doesn't respect -- according to POSIX.

Go flags package

-strflag str is allowed, but -boolflag 0 isn't allowed. Must be -boolflag=0 for negation, or -boolflag / -boolflag=1 when it's true.

Clone this wiki locally