Permalink
Browse files

Test the consistency of shells with regard to parsing empty bodies.

Brought up by Yorwba.

OSH seems to be the most consistent.
  • Loading branch information...
Andy Chu
Andy Chu committed May 28, 2018
1 parent babc25c commit 3315b78f876bd9aef9ef8481f2a857a683eb51a4
Showing with 30 additions and 0 deletions.
  1. +25 −0 spec/empty-bodies.test.sh
  2. +1 −0 spec/for-expr.test.sh
  3. +4 −0 test/spec.sh
View
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
### Empty do/done
while false; do
done
echo empty
# stdout: empty
# OK dash/bash stdout-json: ""
# OK dash/bash status: 2
### Empty case/esac
case foo in
esac
echo empty
# stdout: empty
### empty then/fi
if foo; then
fi
echo empty
# stdout: empty
# OK dash/bash stdout-json: ""
# OK dash/bash status: 2
# OK mksh stdout-json: ""
# OK mksh status: 1
View
@@ -41,3 +41,4 @@ done # A construct borrowed from ksh93.
3
## N-I mksh status: 1
## N-I mksh stdout-json: ""
View
@@ -550,6 +550,10 @@ for-expr() {
$MKSH $BASH $OSH "$@"
}
empty-bodies() {
sh-spec spec/empty-bodies.test.sh "${REF_SHELLS[@]}" $OSH
}
# TODO: This is for the ANTLR grammars, in the oil-sketch repo.
# osh has infinite loop?
shell-grammar() {

0 comments on commit 3315b78

Please sign in to comment.