fish-you-should-use icon indicating copy to clipboard operation
fish-you-should-use copied to clipboard

Use `--` for `string *` commands

Open ilya-bobyr opened this issue 10 months ago • 1 comments

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

ilya-bobyr avatar Mar 29 '24 05:03 ilya-bobyr

Thanks. I was also struggling with this

ccoVeille avatar Mar 29 '24 07:03 ccoVeille