From ca50caacad8354fe97eb0da23075521156c0c0d6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 24 Jul 2017 18:51:40 +0200 Subject: shell: some additions to *sh-misc/* tests Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-misc/assignment2.right | 2 ++ shell/ash_test/ash-misc/assignment2.tests | 3 +++ shell/ash_test/ash-misc/empty_args.right | 6 ++++++ shell/ash_test/ash-misc/empty_args.tests | 9 +++++++++ shell/ash_test/ash-misc/env_and_func.right | 2 ++ shell/ash_test/ash-misc/env_and_func.tests | 8 ++++++++ shell/hush_test/hush-misc/env_and_func.tests | 4 ++++ 7 files changed, 34 insertions(+) create mode 100644 shell/ash_test/ash-misc/assignment2.right create mode 100755 shell/ash_test/ash-misc/assignment2.tests create mode 100644 shell/ash_test/ash-misc/empty_args.right create mode 100755 shell/ash_test/ash-misc/empty_args.tests create mode 100644 shell/ash_test/ash-misc/env_and_func.right create mode 100755 shell/ash_test/ash-misc/env_and_func.tests diff --git a/shell/ash_test/ash-misc/assignment2.right b/shell/ash_test/ash-misc/assignment2.right new file mode 100644 index 000000000..179c71c5a --- /dev/null +++ b/shell/ash_test/ash-misc/assignment2.right @@ -0,0 +1,2 @@ +./assignment2.tests: line 2: a=b: not found +127 diff --git a/shell/ash_test/ash-misc/assignment2.tests b/shell/ash_test/ash-misc/assignment2.tests new file mode 100755 index 000000000..f6938434c --- /dev/null +++ b/shell/ash_test/ash-misc/assignment2.tests @@ -0,0 +1,3 @@ +# This must not be interpreted as an assignment +a''=b true +echo $? diff --git a/shell/ash_test/ash-misc/empty_args.right b/shell/ash_test/ash-misc/empty_args.right new file mode 100644 index 000000000..968b5a4d9 --- /dev/null +++ b/shell/ash_test/ash-misc/empty_args.right @@ -0,0 +1,6 @@ +Null 0th arg: +./empty_args.tests: line 2: : Permission denied +127 +Null 1st arg: +0 +Null arg in exec: diff --git a/shell/ash_test/ash-misc/empty_args.tests b/shell/ash_test/ash-misc/empty_args.tests new file mode 100755 index 000000000..efce5494a --- /dev/null +++ b/shell/ash_test/ash-misc/empty_args.tests @@ -0,0 +1,9 @@ +echo Null 0th arg: +"" +echo $? +echo Null 1st arg: +# printf without args would print usage info +printf "" +echo $? +echo Null arg in exec: +exec printf "" diff --git a/shell/ash_test/ash-misc/env_and_func.right b/shell/ash_test/ash-misc/env_and_func.right new file mode 100644 index 000000000..5fc3488ae --- /dev/null +++ b/shell/ash_test/ash-misc/env_and_func.right @@ -0,0 +1,2 @@ +var=val +var=val diff --git a/shell/ash_test/ash-misc/env_and_func.tests b/shell/ash_test/ash-misc/env_and_func.tests new file mode 100755 index 000000000..3efef1a41 --- /dev/null +++ b/shell/ash_test/ash-misc/env_and_func.tests @@ -0,0 +1,8 @@ +var=old +f() { echo "var=$var"; } +# bash: POSIXLY_CORRECT behavior is to "leak" new variable values +# out of function invocations (similar to "special builtins" behavior); +# but in "bash mode", they don't leak. +# hush does not "leak" values. ash does. +var=val f +echo "var=$var" diff --git a/shell/hush_test/hush-misc/env_and_func.tests b/shell/hush_test/hush-misc/env_and_func.tests index 1d4eaf3a7..3efef1a41 100755 --- a/shell/hush_test/hush-misc/env_and_func.tests +++ b/shell/hush_test/hush-misc/env_and_func.tests @@ -1,4 +1,8 @@ var=old f() { echo "var=$var"; } +# bash: POSIXLY_CORRECT behavior is to "leak" new variable values +# out of function invocations (similar to "special builtins" behavior); +# but in "bash mode", they don't leak. +# hush does not "leak" values. ash does. var=val f echo "var=$var" -- cgit v1.2.3