Bug#1051076: dash: test does not support s1 < s2 or s1 > s2

2023-09-03 Thread Andrej Shadura

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

On Sat, 02 Sep 2023 12:55:34 +0200 Gian Piero Carrubba 
 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



Bug#1051076: dash: test does not support s1 < s2 or s1 > s2

2023-09-02 Thread Gian Piero Carrubba

severity 1051076 grave
thanks

Thinking about it, grave seems a more appropriate severity as the issue 
could cause data loss in case s2 happens to be the pathname of an 
existent file when using the form `test s1 > s2`.




Bug#1051076: dash: test does not support s1 < s2 or s1 > s2

2023-09-02 Thread Gian Piero Carrubba
Package: dash
Version: 0.5.12-6
Severity: normal
Tags: upstream

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

As a side note, '<' and '>' are not mandated by POSIX [3].

Thanks,
Gian Piero.

[0] https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/dash.1
[1]
https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/bltin/test.1
[2]
https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/bltin/test.c
(STRLT and STRGT)
[3] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html


-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.19.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: OpenRC (via /run/openrc), PID 1: init
LSM: AppArmor: enabled

Versions of packages dash depends on:
ii  debianutils  5.11
ii  dpkg 1.22.0
ii  libc62.37-7

dash recommends no packages.

dash suggests no packages.

-- no debconf information