fish-you-should-use
fish-you-should-use copied to clipboard
Use `--` for `string *` commands
string match
, string escape
and friends will try to parse any argument that starts with a -
as a switch. If a string being processed happens to start with a -
it will, most likely, cause an "unknown option" error.
Any string cmd
that uses variables, especially those containing externally provided values, should use --
to indicate the end of the string
command switches and start of the positional parameters.
Consider:
> string match '*a*b' --axxb
string match: --axxb: unknown option
(Type 'help string' for related documentation)
> string match -- '*a*b' --axxb
--axxb
This is causing real errors, for example, as git aliases may start with a switch for git
itself, as in
[alias]
dt = --paginate difftool --tool=difft
Thanks. I was also struggling with this