NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/48498: sh(1) parser oddity
>Number: 48498
>Category: bin
>Synopsis: sh(1) parser oddity
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 04 16:25:00 +0000 2014
>Originator: David A. Holland
>Release: NetBSD 6.99.28 (20131210)
>Organization:
dholland%netbsd.org@localhost
>Environment:
System: NetBSD valkyrie 6.99.28 NetBSD 6.99.28 (VALKYRIE) #14: Tue Dec 10
15:15:49 EST 2013 dholland@valkyrie:/usr/src/sys/arch/amd64/compile/VALKYRIE
amd64
Architecture: x86_64
Machine: amd64
>Description:
sh accepts some curious constructions; while it doesn't accept a plain
"fi", it is happy with a loose "fi" as long as it follows something else:
valkyrie% sh -c 'true; fi'
valkyrie% sh -c 'false; fi'
valkyrie%
Similarly, it accepts "then" without "if" as long as it isn't first:
valkyrie% sh -c 'false; then echo wut'
wut
valkyrie% sh -c 'true; then echo wut'
wut
valkyrie%
Same for "do":
valkyrie% sh -c 'true; do echo wut'
wut
valkyrie%
For that matter you don't even need to have a command there:
valkyrie% sh -c 'true; then'
valkyrie% sh -c 'true; do'
valkyrie%
Needless to say, ksh, bash, and zsh don't allow this sort of thing.
>How-To-Repeat:
>Fix:
torches and pitchforks
Home |
Main Index |
Thread Index |
Old Index