Thread (9 messages) 9 messages, 4 authors, 2021-04-22

Re: [PATCH v3 01/12] check-non-portable-shell: check for "test <cond> -a/-o <cond>"

From: Junio C Hamano <hidden>
Date: 2021-04-20 22:28:39

Possibly related (same subject, not in this thread)

Ævar Arnfjörð Bjarmason  [off-list ref] writes:
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`. We stop at "&" or "|" to try not to overmatch
things like:

    test whatever && ls -a foo
    test whatever && foo -o outfile
I still do not understand why you have to insist on dashed operator
as the first thing given to "test", like this:
+	/\btest\s+-[a-z]\s+[^&|]+\s+-a\s+/ and err '"test A && test B" ...
+	/\btest\s+-[a-z]\s+[^&|]+\s+-o\s+/ and err '"test A || test B" ...
IOW, what over-matching would we get if we simplified the condition
like so?

    /\btest\s+[^&|]+\s+-a\s/
    /\btest\s+[^&|]+\s+-o\s/

The one in the patch would miss things like

	test "$a" = "$b" -o "$a" -lt "$b"
	test "$n" -a "$n" -lt 4

but the only thing that we care about is that a command that started
with "test " has "-a" or "-o" before we see "&" or "|", no?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help