oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.85k stars 159 forks source link

OSH too lenient in parsing the ! operator, e.g. ! true | ! false #2091

Open andychu opened 1 month ago

andychu commented 1 month ago

from https://gist.github.com/izabera/7dcece1d6df9063d43d2b3b0a222e7bb

https://lobste.rs/s/hv0agk/short_bash_quiz


mksh is also too lenient, but other shells agree with bash

$ bash -n -c 'true | ! false; echo $?'
bash: -c: line 1: syntax error near unexpected token `!'
bash: -c: line 1: `true | ! false; echo $?'

andy@hoover:~/git/oilshell/oil$ mksh -n -c 'true | ! false; echo $?'

andy@hoover:~/git/oilshell/oil$ yash -n -c 'true | ! false; echo $?'
yash -c:1: syntax error: `!' cannot be used as a command name

andy@hoover:~/git/oilshell/oil$ bin/osh -n -c 'true | ! false; echo $?'
(command.CommandList
  children: [
    (command.Sentence