Hi,
I'm a contributor to Git and I occasionally run our testsuite in zsh's
emulate sh mode[0]. I discovered today that one of our tests fails when
test's comparison operator is quoted, as is demonstrated by the
following test script:
----
#!/bin/sh -x
zsh -f -c 'emulate sh; test 2 ">" 1'
zsh -f -c 'test 2 ">" 1'
bash -c 'test 2 ">" 1'
dash -c 'test 2 ">" 1'
mksh -c 'test 2 ">" 1'
ksh93 -c 'test 2 ">" 1'
----
On my system, this prints the following:
----
+ zsh -f -c emulate sh; test 2 ">" 1
zsh:1: condition expected: >
+ zsh -f -c test 2 ">" 1
zsh:1: condition expected: >
+ bash -c test 2 ">" 1
+ dash -c test 2 ">" 1
+ mksh -c test 2 ">" 1
+ ksh93 -c test 2 ">" 1
----
In our particular case, we have a function like this:
----
test_line_count () {
if test $# != 3
then
BUG "not 3 parameters to test_line_count"
elif ! test $(wc -l <"$3") "$1" "$2"
then
echo "test_line_count: line count for $3 !$1 $2"
cat "$3"
return 1
fi
}
----
and it fails when called like so, even when `file` contains multiple
lines:
----
test_line_count '>' 1 file
----
As far as I know, this is allowed by POSIX, so it would be good if zsh
allowed it as well.
----
% zsh --version
zsh 5.9 (x86_64-debian-linux-gnu)
----
I'm not subscribed, so please CC me.
[0] I symlink zsh to a file named `sh` and tell Git to use that as its
default shell.
--
brian m. carlson (they/them)
Toronto, Ontario, CA
Attachment:
signature.asc
Description: PGP signature