aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test/hush-misc
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush_test/hush-misc')
-rw-r--r--shell/hush_test/hush-misc/assignment1.right9
-rwxr-xr-xshell/hush_test/hush-misc/assignment1.tests42
-rw-r--r--shell/hush_test/hush-misc/assignment2.rigth2
-rwxr-xr-xshell/hush_test/hush-misc/assignment2.tests4
-rw-r--r--shell/hush_test/hush-misc/break1.right2
-rwxr-xr-xshell/hush_test/hush-misc/break1.tests3
-rw-r--r--shell/hush_test/hush-misc/break2.right3
-rwxr-xr-xshell/hush_test/hush-misc/break2.tests6
-rw-r--r--shell/hush_test/hush-misc/break3.right2
-rwxr-xr-xshell/hush_test/hush-misc/break3.tests2
-rw-r--r--shell/hush_test/hush-misc/break4.right6
-rwxr-xr-xshell/hush_test/hush-misc/break4.tests12
-rw-r--r--shell/hush_test/hush-misc/break5.right13
-rwxr-xr-xshell/hush_test/hush-misc/break5.tests4
-rw-r--r--shell/hush_test/hush-misc/builtin1.right2
-rwxr-xr-xshell/hush_test/hush-misc/builtin1.tests6
-rw-r--r--shell/hush_test/hush-misc/case1.right14
-rwxr-xr-xshell/hush_test/hush-misc/case1.tests25
-rw-r--r--shell/hush_test/hush-misc/colon.right2
-rwxr-xr-xshell/hush_test/hush-misc/colon.tests5
-rw-r--r--shell/hush_test/hush-misc/continue1.right8
-rwxr-xr-xshell/hush_test/hush-misc/continue1.tests4
-rw-r--r--shell/hush_test/hush-misc/empty_for.right1
-rwxr-xr-xshell/hush_test/hush-misc/empty_for.tests3
-rw-r--r--shell/hush_test/hush-misc/empty_for2.right4
-rwxr-xr-xshell/hush_test/hush-misc/empty_for2.tests6
-rw-r--r--shell/hush_test/hush-misc/for_with_keywords.right4
-rwxr-xr-xshell/hush_test/hush-misc/for_with_keywords.tests2
-rw-r--r--shell/hush_test/hush-misc/pid.right1
-rwxr-xr-xshell/hush_test/hush-misc/pid.tests1
-rw-r--r--shell/hush_test/hush-misc/read.right4
-rwxr-xr-xshell/hush_test/hush-misc/read.tests4
-rw-r--r--shell/hush_test/hush-misc/shift.right6
-rwxr-xr-xshell/hush_test/hush-misc/shift.tests14
-rw-r--r--shell/hush_test/hush-misc/syntax_err.right2
-rwxr-xr-xshell/hush_test/hush-misc/syntax_err.tests3
-rw-r--r--shell/hush_test/hush-misc/syntax_err_negate.right2
-rwxr-xr-xshell/hush_test/hush-misc/syntax_err_negate.tests2
-rw-r--r--shell/hush_test/hush-misc/while1.right1
-rwxr-xr-xshell/hush_test/hush-misc/while1.tests2
-rw-r--r--shell/hush_test/hush-misc/while_in_subshell.right1
-rwxr-xr-xshell/hush_test/hush-misc/while_in_subshell.tests2
42 files changed, 241 insertions, 0 deletions
diff --git a/shell/hush_test/hush-misc/assignment1.right b/shell/hush_test/hush-misc/assignment1.right
new file mode 100644
index 0000000..d0a13d3
--- /dev/null
+++ b/shell/hush_test/hush-misc/assignment1.right
@@ -0,0 +1,9 @@
+if1:0
+while1:0
+until1:0
+if2:0
+while2:0
+until2:0
+if3:0
+while3:0
+until3:0
diff --git a/shell/hush_test/hush-misc/assignment1.tests b/shell/hush_test/hush-misc/assignment1.tests
new file mode 100755
index 0000000..033b352
--- /dev/null
+++ b/shell/hush_test/hush-misc/assignment1.tests
@@ -0,0 +1,42 @@
+# Assignments after some keywords should still work
+
+if a=1 true; then a=1 true; elif a=1 true; then a=1 true; else a=1 true; fi
+echo if1:$?
+while a=1 true; do a=1 true; break; done
+echo while1:$?
+until a=1 false; do a=1 true; break; done
+echo until1:$?
+
+if a=1 true
+ then a=1 true
+ elif a=1 true
+ then a=1 true
+ else a=1 true
+ fi
+echo if2:$?
+while a=1 true
+ do a=1 true
+ break
+ done
+echo while2:$?
+until a=1 false
+ do a=1 true
+ break
+ done
+echo until2:$?
+
+if
+ a=1 true; then
+ a=1 true; elif
+ a=1 true; then
+ a=1 true; else
+ a=1 true; fi
+echo if3:$?
+while
+ a=1 true; do
+ a=1 true; break; done
+echo while3:$?
+until
+ a=1 false; do
+ a=1 true; break; done
+echo until3:$?
diff --git a/shell/hush_test/hush-misc/assignment2.rigth b/shell/hush_test/hush-misc/assignment2.rigth
new file mode 100644
index 0000000..591552c
--- /dev/null
+++ b/shell/hush_test/hush-misc/assignment2.rigth
@@ -0,0 +1,2 @@
+hush: can't exec 'a=b': No such file or directory
+1
diff --git a/shell/hush_test/hush-misc/assignment2.tests b/shell/hush_test/hush-misc/assignment2.tests
new file mode 100755
index 0000000..540e01e
--- /dev/null
+++ b/shell/hush_test/hush-misc/assignment2.tests
@@ -0,0 +1,4 @@
+# This must not be interpreted as an assignment
+a''=b true
+echo $?
+# (buglet: $? should be 127. it is currently 1)
diff --git a/shell/hush_test/hush-misc/break1.right b/shell/hush_test/hush-misc/break1.right
new file mode 100644
index 0000000..04a4b17
--- /dev/null
+++ b/shell/hush_test/hush-misc/break1.right
@@ -0,0 +1,2 @@
+A
+OK:0
diff --git a/shell/hush_test/hush-misc/break1.tests b/shell/hush_test/hush-misc/break1.tests
new file mode 100755
index 0000000..912f149
--- /dev/null
+++ b/shell/hush_test/hush-misc/break1.tests
@@ -0,0 +1,3 @@
+while true; do echo A; break; echo B; done
+echo OK:$?
+
diff --git a/shell/hush_test/hush-misc/break2.right b/shell/hush_test/hush-misc/break2.right
new file mode 100644
index 0000000..8a15cb9
--- /dev/null
+++ b/shell/hush_test/hush-misc/break2.right
@@ -0,0 +1,3 @@
+A
+AA
+OK:0
diff --git a/shell/hush_test/hush-misc/break2.tests b/shell/hush_test/hush-misc/break2.tests
new file mode 100755
index 0000000..7da9faf
--- /dev/null
+++ b/shell/hush_test/hush-misc/break2.tests
@@ -0,0 +1,6 @@
+while true; do
+ echo A
+ while true; do echo AA; break 2; echo BB; done
+ echo B
+done
+echo OK:$?
diff --git a/shell/hush_test/hush-misc/break3.right b/shell/hush_test/hush-misc/break3.right
new file mode 100644
index 0000000..04a4b17
--- /dev/null
+++ b/shell/hush_test/hush-misc/break3.right
@@ -0,0 +1,2 @@
+A
+OK:0
diff --git a/shell/hush_test/hush-misc/break3.tests b/shell/hush_test/hush-misc/break3.tests
new file mode 100755
index 0000000..d138dca
--- /dev/null
+++ b/shell/hush_test/hush-misc/break3.tests
@@ -0,0 +1,2 @@
+v=break; while true; do echo A; $v; echo B; break; echo C; done
+echo OK:$?
diff --git a/shell/hush_test/hush-misc/break4.right b/shell/hush_test/hush-misc/break4.right
new file mode 100644
index 0000000..6f41c14
--- /dev/null
+++ b/shell/hush_test/hush-misc/break4.right
@@ -0,0 +1,6 @@
+A
+AA
+TRUE
+A
+AA
+OK:0
diff --git a/shell/hush_test/hush-misc/break4.tests b/shell/hush_test/hush-misc/break4.tests
new file mode 100755
index 0000000..67da288
--- /dev/null
+++ b/shell/hush_test/hush-misc/break4.tests
@@ -0,0 +1,12 @@
+cond=true
+while $cond; do
+ echo A
+ if test "$cond" = true; then
+ cond='echo TRUE'
+ else
+ cond=false
+ fi
+ while true; do echo AA; continue 2; echo BB; done
+ echo B
+done
+echo OK:$?
diff --git a/shell/hush_test/hush-misc/break5.right b/shell/hush_test/hush-misc/break5.right
new file mode 100644
index 0000000..0b9df2a
--- /dev/null
+++ b/shell/hush_test/hush-misc/break5.right
@@ -0,0 +1,13 @@
+A
+B
+0
+A:a
+B
+D
+A:b
+B
+D
+A:c
+B
+D
+0
diff --git a/shell/hush_test/hush-misc/break5.tests b/shell/hush_test/hush-misc/break5.tests
new file mode 100755
index 0000000..273e040
--- /dev/null
+++ b/shell/hush_test/hush-misc/break5.tests
@@ -0,0 +1,4 @@
+while true; do echo A; { echo B; break; echo C; }; echo D; done
+echo $?
+for v in a b c; do echo A:$v; (echo B; break; echo C); echo D; done
+echo $?
diff --git a/shell/hush_test/hush-misc/builtin1.right b/shell/hush_test/hush-misc/builtin1.right
new file mode 100644
index 0000000..2e55ecb
--- /dev/null
+++ b/shell/hush_test/hush-misc/builtin1.right
@@ -0,0 +1,2 @@
+VARIABLE=export
+OK:0
diff --git a/shell/hush_test/hush-misc/builtin1.tests b/shell/hush_test/hush-misc/builtin1.tests
new file mode 100755
index 0000000..1a2941f
--- /dev/null
+++ b/shell/hush_test/hush-misc/builtin1.tests
@@ -0,0 +1,6 @@
+# builtins, unlike keywords like "while", can be constructed
+# with substitutions
+VARIABLE=export
+$VARIABLE VARIABLE
+env | grep ^VARIABLE
+echo OK:$?
diff --git a/shell/hush_test/hush-misc/case1.right b/shell/hush_test/hush-misc/case1.right
new file mode 100644
index 0000000..e9e371a
--- /dev/null
+++ b/shell/hush_test/hush-misc/case1.right
@@ -0,0 +1,14 @@
+OK_1
+OK_1
+OK_21
+OK_22
+OK_23
+OK_31
+OK_32
+OK_41
+OK_42
+OK_43
+OK_44
+OK_51
+OK_52
+OK_53
diff --git a/shell/hush_test/hush-misc/case1.tests b/shell/hush_test/hush-misc/case1.tests
new file mode 100755
index 0000000..0174893
--- /dev/null
+++ b/shell/hush_test/hush-misc/case1.tests
@@ -0,0 +1,25 @@
+case w in a) echo SKIP;; w) echo OK_1;; w) echo WRONG;; esac
+
+case w in
+ a) echo SKIP;;
+ w)echo OK_1 ;;
+ w)
+ echo WRONG
+ ;;
+esac
+
+t=w
+case $t in a) echo SKIP;; w) echo OK_21;; w) echo WRONG;; esac;
+case "$t" in a) echo SKIP;; w) echo OK_22;; w) echo WRONG;; esac;
+case w in a) echo SKIP;; $t) echo OK_23;; "$t") echo WRONG;; esac;
+
+case '' in a) echo SKIP;; w) echo WRONG;; *) echo OK_31;; esac;
+case '' in a) echo SKIP;; '') echo OK_32;; *) echo WRONG;; esac;
+
+case `echo w` in a) echo SKIP;; w) echo OK_41;; w) echo WRONG;; esac;
+case "`echo w`" in a) echo SKIP;; w) echo OK_42;; w) echo WRONG;; esac;
+case `echo w w` in a) echo SKIP;; w) echo WRONG;; 'w w') echo OK_43;; esac;
+case `echo w w` in a) echo SKIP;; w) echo WRONG;; w*) echo OK_44;; esac;
+
+case w in `echo w`) echo OK_51;; `echo WRONG >&2`w) echo WRONG;; esac;
+case w in `echo OK_52 >&2`) echo SKIP;; `echo`w) echo OK_53;; esac;
diff --git a/shell/hush_test/hush-misc/colon.right b/shell/hush_test/hush-misc/colon.right
new file mode 100644
index 0000000..2a87d02
--- /dev/null
+++ b/shell/hush_test/hush-misc/colon.right
@@ -0,0 +1,2 @@
+0
+OK: 0
diff --git a/shell/hush_test/hush-misc/colon.tests b/shell/hush_test/hush-misc/colon.tests
new file mode 100755
index 0000000..cb8ab53
--- /dev/null
+++ b/shell/hush_test/hush-misc/colon.tests
@@ -0,0 +1,5 @@
+false
+:
+echo $?
+(while :; do exit; done)
+echo OK: $?
diff --git a/shell/hush_test/hush-misc/continue1.right b/shell/hush_test/hush-misc/continue1.right
new file mode 100644
index 0000000..c4a5565
--- /dev/null
+++ b/shell/hush_test/hush-misc/continue1.right
@@ -0,0 +1,8 @@
+A:a
+A:b
+A:c
+OK1
+A:a
+A:b
+A:c
+OK2
diff --git a/shell/hush_test/hush-misc/continue1.tests b/shell/hush_test/hush-misc/continue1.tests
new file mode 100755
index 0000000..72d3566
--- /dev/null
+++ b/shell/hush_test/hush-misc/continue1.tests
@@ -0,0 +1,4 @@
+for v in a b c; do echo A:$v; continue 666; done
+echo OK1
+for v in a b c; do echo A:$v; continue 666; done
+echo OK2
diff --git a/shell/hush_test/hush-misc/empty_for.right b/shell/hush_test/hush-misc/empty_for.right
new file mode 100644
index 0000000..290d39b
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_for.right
@@ -0,0 +1 @@
+OK: 0
diff --git a/shell/hush_test/hush-misc/empty_for.tests b/shell/hush_test/hush-misc/empty_for.tests
new file mode 100755
index 0000000..0cb52e8
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_for.tests
@@ -0,0 +1,3 @@
+false
+for a in; do echo "HELLO"; done
+echo OK: $?
diff --git a/shell/hush_test/hush-misc/empty_for2.right b/shell/hush_test/hush-misc/empty_for2.right
new file mode 100644
index 0000000..1acee9e
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_for2.right
@@ -0,0 +1,4 @@
+PARAM:abc
+PARAM:d e
+PARAM:123
+OK: 0
diff --git a/shell/hush_test/hush-misc/empty_for2.tests b/shell/hush_test/hush-misc/empty_for2.tests
new file mode 100755
index 0000000..2b12ec2
--- /dev/null
+++ b/shell/hush_test/hush-misc/empty_for2.tests
@@ -0,0 +1,6 @@
+if test $# = 0; then
+ exec "$THIS_SH" $0 abc "d e" 123
+fi
+false
+for v; do echo "PARAM:$v"; done
+echo OK: $?
diff --git a/shell/hush_test/hush-misc/for_with_keywords.right b/shell/hush_test/hush-misc/for_with_keywords.right
new file mode 100644
index 0000000..eb04e9a
--- /dev/null
+++ b/shell/hush_test/hush-misc/for_with_keywords.right
@@ -0,0 +1,4 @@
+do
+done
+then
+OK: 0
diff --git a/shell/hush_test/hush-misc/for_with_keywords.tests b/shell/hush_test/hush-misc/for_with_keywords.tests
new file mode 100755
index 0000000..a8b8e42
--- /dev/null
+++ b/shell/hush_test/hush-misc/for_with_keywords.tests
@@ -0,0 +1,2 @@
+for if in do done then; do echo $if; done
+echo OK: $?
diff --git a/shell/hush_test/hush-misc/pid.right b/shell/hush_test/hush-misc/pid.right
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/shell/hush_test/hush-misc/pid.right
@@ -0,0 +1 @@
+0
diff --git a/shell/hush_test/hush-misc/pid.tests b/shell/hush_test/hush-misc/pid.tests
new file mode 100755
index 0000000..eaeaa71
--- /dev/null
+++ b/shell/hush_test/hush-misc/pid.tests
@@ -0,0 +1 @@
+test `(echo $$)` = `echo $$`; echo $?
diff --git a/shell/hush_test/hush-misc/read.right b/shell/hush_test/hush-misc/read.right
new file mode 100644
index 0000000..0e50e2a
--- /dev/null
+++ b/shell/hush_test/hush-misc/read.right
@@ -0,0 +1,4 @@
+read
+cat
+echo "REPLY=$REPLY"
+REPLY=exec <read.tests
diff --git a/shell/hush_test/hush-misc/read.tests b/shell/hush_test/hush-misc/read.tests
new file mode 100755
index 0000000..ff1acbd
--- /dev/null
+++ b/shell/hush_test/hush-misc/read.tests
@@ -0,0 +1,4 @@
+exec <read.tests
+read
+cat
+echo "REPLY=$REPLY"
diff --git a/shell/hush_test/hush-misc/shift.right b/shell/hush_test/hush-misc/shift.right
new file mode 100644
index 0000000..d281e35
--- /dev/null
+++ b/shell/hush_test/hush-misc/shift.right
@@ -0,0 +1,6 @@
+./shift.tests abc d e
+./shift.tests d e 123
+./shift.tests d e 123
+./shift.tests
+./shift.tests
+./shift.tests
diff --git a/shell/hush_test/hush-misc/shift.tests b/shell/hush_test/hush-misc/shift.tests
new file mode 100755
index 0000000..53ef249
--- /dev/null
+++ b/shell/hush_test/hush-misc/shift.tests
@@ -0,0 +1,14 @@
+if test $# = 0; then
+ exec "$THIS_SH" $0 abc "d e" 123
+fi
+echo $0 $1 $2
+shift
+echo $0 $1 $2
+shift 999
+echo $0 $1 $2
+shift 2
+echo $0 $1 $2
+shift 2
+echo $0 $1 $2
+shift
+echo $0 $1 $2
diff --git a/shell/hush_test/hush-misc/syntax_err.right b/shell/hush_test/hush-misc/syntax_err.right
new file mode 100644
index 0000000..08a270c
--- /dev/null
+++ b/shell/hush_test/hush-misc/syntax_err.right
@@ -0,0 +1,2 @@
+shown
+hush: syntax error: unterminated '
diff --git a/shell/hush_test/hush-misc/syntax_err.tests b/shell/hush_test/hush-misc/syntax_err.tests
new file mode 100755
index 0000000..d10ed42
--- /dev/null
+++ b/shell/hush_test/hush-misc/syntax_err.tests
@@ -0,0 +1,3 @@
+echo shown
+echo test `echo 'aa`
+echo not shown
diff --git a/shell/hush_test/hush-misc/syntax_err_negate.right b/shell/hush_test/hush-misc/syntax_err_negate.right
new file mode 100644
index 0000000..d1e7654
--- /dev/null
+++ b/shell/hush_test/hush-misc/syntax_err_negate.right
@@ -0,0 +1,2 @@
+bash 3.2 fails this
+hush: syntax error
diff --git a/shell/hush_test/hush-misc/syntax_err_negate.tests b/shell/hush_test/hush-misc/syntax_err_negate.tests
new file mode 100755
index 0000000..d61b1b0
--- /dev/null
+++ b/shell/hush_test/hush-misc/syntax_err_negate.tests
@@ -0,0 +1,2 @@
+echo bash 3.2 fails this
+! ! true
diff --git a/shell/hush_test/hush-misc/while1.right b/shell/hush_test/hush-misc/while1.right
new file mode 100644
index 0000000..7c4d7be
--- /dev/null
+++ b/shell/hush_test/hush-misc/while1.right
@@ -0,0 +1 @@
+OK:0
diff --git a/shell/hush_test/hush-misc/while1.tests b/shell/hush_test/hush-misc/while1.tests
new file mode 100755
index 0000000..11e201e
--- /dev/null
+++ b/shell/hush_test/hush-misc/while1.tests
@@ -0,0 +1,2 @@
+while false; do echo NOT SHOWN; done
+echo OK:$?
diff --git a/shell/hush_test/hush-misc/while_in_subshell.right b/shell/hush_test/hush-misc/while_in_subshell.right
new file mode 100644
index 0000000..290d39b
--- /dev/null
+++ b/shell/hush_test/hush-misc/while_in_subshell.right
@@ -0,0 +1 @@
+OK: 0
diff --git a/shell/hush_test/hush-misc/while_in_subshell.tests b/shell/hush_test/hush-misc/while_in_subshell.tests
new file mode 100755
index 0000000..def8e09
--- /dev/null
+++ b/shell/hush_test/hush-misc/while_in_subshell.tests
@@ -0,0 +1,2 @@
+(while true; do exit; done)
+echo OK: $?