aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash_test/ash-redir/redir1.right (renamed from shell/hush_test/hush-misc/redir1.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir1.tests (renamed from shell/hush_test/hush-misc/redir1.tests)0
-rw-r--r--shell/ash_test/ash-redir/redir_script.right (renamed from shell/hush_test/hush-misc/redir_script.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_script.tests (renamed from shell/hush_test/hush-misc/redir_script.tests)0
-rw-r--r--shell/ash_test/ash-redir/redir_space.right (renamed from shell/hush_test/hush-parsing/redir_space.right)0
-rwxr-xr-xshell/ash_test/ash-redir/redir_space.tests (renamed from shell/hush_test/hush-parsing/redir_space.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir1.right12
-rwxr-xr-xshell/hush_test/hush-redir/redir1.tests40
-rw-r--r--shell/hush_test/hush-redir/redir2.right (renamed from shell/hush_test/hush-misc/redir2.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir2.tests (renamed from shell/hush_test/hush-misc/redir2.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir3.right (renamed from shell/hush_test/hush-misc/redir3.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir3.tests (renamed from shell/hush_test/hush-misc/redir3.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir4.right (renamed from shell/hush_test/hush-misc/redir4.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir4.tests (renamed from shell/hush_test/hush-misc/redir4.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir5.right (renamed from shell/hush_test/hush-misc/redir5.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir5.tests (renamed from shell/hush_test/hush-misc/redir5.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir6.right (renamed from shell/hush_test/hush-misc/redir6.right)0
-rwxr-xr-xshell/hush_test/hush-redir/redir6.tests (renamed from shell/hush_test/hush-misc/redir6.tests)0
-rw-r--r--shell/hush_test/hush-redir/redir7.right3
-rwxr-xr-xshell/hush_test/hush-redir/redir7.tests12
-rw-r--r--shell/hush_test/hush-redir/redir8.right3
-rwxr-xr-xshell/hush_test/hush-redir/redir8.tests15
-rw-r--r--shell/hush_test/hush-redir/redir9.right2
-rwxr-xr-xshell/hush_test/hush-redir/redir9.tests4
-rw-r--r--shell/hush_test/hush-redir/redirA.right2
-rwxr-xr-xshell/hush_test/hush-redir/redirA.tests11
-rw-r--r--shell/hush_test/hush-redir/redir_script.right1
-rwxr-xr-xshell/hush_test/hush-redir/redir_script.tests29
-rw-r--r--shell/hush_test/hush-redir/redir_space.right3
-rwxr-xr-xshell/hush_test/hush-redir/redir_space.tests6
30 files changed, 143 insertions, 0 deletions
diff --git a/shell/hush_test/hush-misc/redir1.right b/shell/ash_test/ash-redir/redir1.right
index 15515d1af..15515d1af 100644
--- a/shell/hush_test/hush-misc/redir1.right
+++ b/shell/ash_test/ash-redir/redir1.right
diff --git a/shell/hush_test/hush-misc/redir1.tests b/shell/ash_test/ash-redir/redir1.tests
index ef2fbfb77..ef2fbfb77 100755
--- a/shell/hush_test/hush-misc/redir1.tests
+++ b/shell/ash_test/ash-redir/redir1.tests
diff --git a/shell/hush_test/hush-misc/redir_script.right b/shell/ash_test/ash-redir/redir_script.right
index 6694ed334..6694ed334 100644
--- a/shell/hush_test/hush-misc/redir_script.right
+++ b/shell/ash_test/ash-redir/redir_script.right
diff --git a/shell/hush_test/hush-misc/redir_script.tests b/shell/ash_test/ash-redir/redir_script.tests
index ccc497d7b..ccc497d7b 100755
--- a/shell/hush_test/hush-misc/redir_script.tests
+++ b/shell/ash_test/ash-redir/redir_script.tests
diff --git a/shell/hush_test/hush-parsing/redir_space.right b/shell/ash_test/ash-redir/redir_space.right
index 084295204..084295204 100644
--- a/shell/hush_test/hush-parsing/redir_space.right
+++ b/shell/ash_test/ash-redir/redir_space.right
diff --git a/shell/hush_test/hush-parsing/redir_space.tests b/shell/ash_test/ash-redir/redir_space.tests
index c0b543098..c0b543098 100755
--- a/shell/hush_test/hush-parsing/redir_space.tests
+++ b/shell/ash_test/ash-redir/redir_space.tests
diff --git a/shell/hush_test/hush-redir/redir1.right b/shell/hush_test/hush-redir/redir1.right
new file mode 100644
index 000000000..15515d1af
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir1.right
@@ -0,0 +1,12 @@
+Test 0: var:ok
+File created:ok
+Test 1: var:ok
+File created:ok
+Test 2: var:ok
+File created:ok
+Test 3: var:ok
+File created:ok
+Test 4: var:ok
+File created:ok
+Test 5: var:ok
+File created:ok
diff --git a/shell/hush_test/hush-redir/redir1.tests b/shell/hush_test/hush-redir/redir1.tests
new file mode 100755
index 000000000..ef2fbfb77
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir1.tests
@@ -0,0 +1,40 @@
+rm shell_test_$$ 2>/dev/null
+var=bad
+>shell_test_$$ var=ok
+echo "Test 0: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
+var=bad
+var=ok >shell_test_$$
+echo "Test 1: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
+var=ok
+true | var=bad >shell_test_$$
+echo "Test 2: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
+var=bad
+{ var=ok >shell_test_$$; }
+echo "Test 3: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
+var=ok
+{ var=bad >shell_test_$$; } &
+# cant use usleep as it isnt standard in $PATH --
+# we fail when testing busybox compiled solely as "hush"
+wait
+echo "Test 4: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
+var=ok
+( var=bad >shell_test_$$ )
+echo "Test 5: var:$var"
+test -f shell_test_$$ && echo "File created:ok"
+
+rm shell_test_$$ 2>/dev/null
diff --git a/shell/hush_test/hush-misc/redir2.right b/shell/hush_test/hush-redir/redir2.right
index 7326d9603..7326d9603 100644
--- a/shell/hush_test/hush-misc/redir2.right
+++ b/shell/hush_test/hush-redir/redir2.right
diff --git a/shell/hush_test/hush-misc/redir2.tests b/shell/hush_test/hush-redir/redir2.tests
index 81983cae2..81983cae2 100755
--- a/shell/hush_test/hush-misc/redir2.tests
+++ b/shell/hush_test/hush-redir/redir2.tests
diff --git a/shell/hush_test/hush-misc/redir3.right b/shell/hush_test/hush-redir/redir3.right
index 3d20bbf68..3d20bbf68 100644
--- a/shell/hush_test/hush-misc/redir3.right
+++ b/shell/hush_test/hush-redir/redir3.right
diff --git a/shell/hush_test/hush-misc/redir3.tests b/shell/hush_test/hush-redir/redir3.tests
index 7c28e4324..7c28e4324 100755
--- a/shell/hush_test/hush-misc/redir3.tests
+++ b/shell/hush_test/hush-redir/redir3.tests
diff --git a/shell/hush_test/hush-misc/redir4.right b/shell/hush_test/hush-redir/redir4.right
index ead25f603..ead25f603 100644
--- a/shell/hush_test/hush-misc/redir4.right
+++ b/shell/hush_test/hush-redir/redir4.right
diff --git a/shell/hush_test/hush-misc/redir4.tests b/shell/hush_test/hush-redir/redir4.tests
index c50b8cedf..c50b8cedf 100755
--- a/shell/hush_test/hush-misc/redir4.tests
+++ b/shell/hush_test/hush-redir/redir4.tests
diff --git a/shell/hush_test/hush-misc/redir5.right b/shell/hush_test/hush-redir/redir5.right
index 52cce4feb..52cce4feb 100644
--- a/shell/hush_test/hush-misc/redir5.right
+++ b/shell/hush_test/hush-redir/redir5.right
diff --git a/shell/hush_test/hush-misc/redir5.tests b/shell/hush_test/hush-redir/redir5.tests
index 957f9c81f..957f9c81f 100755
--- a/shell/hush_test/hush-misc/redir5.tests
+++ b/shell/hush_test/hush-redir/redir5.tests
diff --git a/shell/hush_test/hush-misc/redir6.right b/shell/hush_test/hush-redir/redir6.right
index a97c4bdf1..a97c4bdf1 100644
--- a/shell/hush_test/hush-misc/redir6.right
+++ b/shell/hush_test/hush-redir/redir6.right
diff --git a/shell/hush_test/hush-misc/redir6.tests b/shell/hush_test/hush-redir/redir6.tests
index c639ebb2d..c639ebb2d 100755
--- a/shell/hush_test/hush-misc/redir6.tests
+++ b/shell/hush_test/hush-redir/redir6.tests
diff --git a/shell/hush_test/hush-redir/redir7.right b/shell/hush_test/hush-redir/redir7.right
new file mode 100644
index 000000000..6430b0211
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir7.right
@@ -0,0 +1,3 @@
+Ok
+Ok
+Done
diff --git a/shell/hush_test/hush-redir/redir7.tests b/shell/hush_test/hush-redir/redir7.tests
new file mode 100755
index 000000000..e873a4622
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir7.tests
@@ -0,0 +1,12 @@
+# Chars above 0x7f are used as special codes.
+# 0x81 is CTLESC (see ash.c).
+# The bug was that quoting and unquoting of them
+# was out of sync for redirect filenames.
+
+>unicode.sh
+printf 'echo Ok >uni\x81code\n' >>unicode.sh
+printf 'cat uni\x81code\n' >>unicode.sh
+printf 'cat uni?code\n' >>unicode.sh
+. ./unicode.sh
+rm uni*code*
+echo Done
diff --git a/shell/hush_test/hush-redir/redir8.right b/shell/hush_test/hush-redir/redir8.right
new file mode 100644
index 000000000..6430b0211
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir8.right
@@ -0,0 +1,3 @@
+Ok
+Ok
+Done
diff --git a/shell/hush_test/hush-redir/redir8.tests b/shell/hush_test/hush-redir/redir8.tests
new file mode 100755
index 000000000..2bd386749
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir8.tests
@@ -0,0 +1,15 @@
+# Chars above 0x7f are used as special codes.
+# 0x81 is CTLESC (see ash.c).
+# The bug was that quoting and unquoting of them
+# was out of sync for redirect filenames.
+
+# Subcase when redirect filename is specified in a variable.
+
+>unicode.sh
+printf 'v=uni\x81code\n' >>unicode.sh
+printf 'echo Ok >"$v"\n' >>unicode.sh
+printf 'cat uni\x81code\n' >>unicode.sh
+printf 'cat uni?code\n' >>unicode.sh
+. ./unicode.sh
+rm uni*code*
+echo Done
diff --git a/shell/hush_test/hush-redir/redir9.right b/shell/hush_test/hush-redir/redir9.right
new file mode 100644
index 000000000..34c2512e4
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir9.right
@@ -0,0 +1,2 @@
+Ok
+Done:0
diff --git a/shell/hush_test/hush-redir/redir9.tests b/shell/hush_test/hush-redir/redir9.tests
new file mode 100755
index 000000000..8befa611c
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir9.tests
@@ -0,0 +1,4 @@
+echo Ok >file.tmp
+cat 0<>file.tmp
+echo Done:$?
+rm file.tmp
diff --git a/shell/hush_test/hush-redir/redirA.right b/shell/hush_test/hush-redir/redirA.right
new file mode 100644
index 000000000..31406e336
--- /dev/null
+++ b/shell/hush_test/hush-redir/redirA.right
@@ -0,0 +1,2 @@
+tmp11
+tmp11
diff --git a/shell/hush_test/hush-redir/redirA.tests b/shell/hush_test/hush-redir/redirA.tests
new file mode 100755
index 000000000..56833f938
--- /dev/null
+++ b/shell/hush_test/hush-redir/redirA.tests
@@ -0,0 +1,11 @@
+x="tmp11:tmp22"
+
+# Bug was incorrectly expanding variables in >redir
+echo "${x%:*}" >"${x%:*}"
+echo tmp1*
+rm tmp1*
+
+# Also try unquoted
+echo "${x%:*}" >${x%:*}
+echo tmp1*
+rm tmp1*
diff --git a/shell/hush_test/hush-redir/redir_script.right b/shell/hush_test/hush-redir/redir_script.right
new file mode 100644
index 000000000..6694ed334
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir_script.right
@@ -0,0 +1 @@
+Ok: script fd is not closed
diff --git a/shell/hush_test/hush-redir/redir_script.tests b/shell/hush_test/hush-redir/redir_script.tests
new file mode 100755
index 000000000..ccc497d7b
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir_script.tests
@@ -0,0 +1,29 @@
+# Builds a " 3>&- 4>&-" string.
+# Note: one of these fds is a directory opened to /proc/self/fd
+# for globbing. It is unwanted, but I don't know how to filter it out.
+find_fds() {
+ fds=""
+ for f in /proc/self/fd/*; do
+ test "$f" = "/proc/self/fd/0" && continue
+ test "$f" = "/proc/self/fd/1" && continue
+ test "$f" = "/proc/self/fd/2" && continue
+ fds="$fds ${f##*/}>&-"
+ done
+}
+
+find_fds
+fds1="$fds"
+
+# One of the fds is open to the script body
+# Close it while executing something.
+eval "find_fds $fds"
+
+# Shell should not lose that fd. Did it?
+find_fds
+test x"$fds1" = x"$fds" && { echo "Ok: script fd is not closed"; exit 0; }
+
+echo "Bug: script fd is closed"
+echo "fds1:$fds1"
+echo "fds2:$fds"
+exit 1
+
diff --git a/shell/hush_test/hush-redir/redir_space.right b/shell/hush_test/hush-redir/redir_space.right
new file mode 100644
index 000000000..084295204
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir_space.right
@@ -0,0 +1,3 @@
+z1.tmp: 1
+z2.tmp: 1
+"z1.tmp z2.tmp": TEST 0
diff --git a/shell/hush_test/hush-redir/redir_space.tests b/shell/hush_test/hush-redir/redir_space.tests
new file mode 100755
index 000000000..c0b543098
--- /dev/null
+++ b/shell/hush_test/hush-redir/redir_space.tests
@@ -0,0 +1,6 @@
+v='z1.tmp z2.tmp'
+echo TEST >$v
+echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?`
+echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?`
+echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?`
+rm z*.tmp