Control: severity -1 normal
Control: tag -1 wontfix

On Sat, 02 Sep 2023 12:55:34 +0200 Gian Piero Carrubba <debian-...@rm-rf.it> wrote:
dash supposedly implements test s1 < s2 and test s1 > s2 for string
comparisons. A cursory glance at [0], [1] and [2] seems to confirm this.

Anyway the shell redirection seems to take precedence so that the test
is not actually performed.

> dash
$ type test
test is a shell builtin
$ ls -l bar
ls: cannot access 'bar': No such file or directory
$ test "foo" < "bar"
dash: 2: cannot open bar: No such file
$ test "foo" > "bar"
$ ls -l bar
-rw-r--r-- 1 gpiero gpiero 0 Sep  2 12:51 bar

You forgot to escape the < and >:

$ test foo '>' bar
$ echo $?
0
$ test foo '<' bar
$ echo $?
1

--
Cheers,
  Andrej

Reply via email to