NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/57997: sh(1) allows an empty list in if statements
>Number: 57997
>Category: bin
>Synopsis: sh(1) allows an empty list in if statements
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 04 18:30:01 +0000 2024
>Originator: RVP
>Release: NetBSD-10.99.10
>Organization:
>Environment:
NetBSD CoreBook.local 10.99.10 NetBSD 10.99.10 (MYKERNEL) #0: Sun Mar 3 03:37:44 UTC 2024 bld@CoreBook.local:/tmp/obj/usr/src/sys/arch/amd64/compile/MYKERNEL amd64
>Description:
Apparently, NetBSD's sh(1) doesn't need a `list' after `then' in `if'
statements:
```
#!/bin/sh
if false
then
elif false
then
else
fi
echo "Should not reach this!"
```
NetBSD's /bin/sh first here, then some other shells:
```
$ ./then.sh
Should not reach this!
$ bash ./then.sh
./then.sh: line 5: syntax error near unexpected token `elif'
./then.sh: line 5: `elif false'
$ ksh ./then.sh
./then.sh[5]: syntax error: `elif' unexpected
./then.sh[5]:
$ ksh93 ./then.sh
./then.sh: syntax error at line 5: `elif' unexpected
$ dash ./then.sh
./then.sh: 5: Syntax error: "elif" unexpected
```
This is the case even in NetBSD 9.3. Haven't checked 8.x. First noticed
in the rehash() function of /usr/sbin/certctl.
>How-To-Repeat:
As above.
>Fix:
No clue.
Home |
Main Index |
Thread Index |
Old Index