Re: [PATCH 01/16] check-non-portable-shell: complain about "test" a/-o instead of &&/||
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 12 quoted lines
> Given that these flags are considered obsolescent, thus may someday be
> dropped from some implementations, these seem a better fit for the
> "portability issues" section than the "coding style preferences"
> section. (I'd probably just drop those section titles, though.)
>
>> + /\btest\s+-[a-z]\s+.*?\s+-a\s+/ and err '"test A && test B" preferred to "test A -a B"';
>> + /\btest\s+-[a-z]\s+.*?\s+-o\s+/ and err '"test A || test B" preferred to "test A -o B"';
>
> These will only match the simplistic forms of `test -X blah` (where
> "-X" is some single letter option), but will miss expressions such as
> `test "$foo" = bar`. Crafting a regex to match more generally would be
> non-trivial, so this simpler match is a reasonable start. Okay.
Would it be a trivial improvement to do
'test', followed by anything other than '&' or '|', and then
followed by '-a' or '-o'instead?