summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2005-06-21 21:43:38 +0000
committergad <gad@FreeBSD.org>2005-06-21 21:43:38 +0000
commit2628b26a5edabadc373f8e3e63d70dbf449fc99c (patch)
treeb7645e43733a0c84d9f129e6c7b1da3194d5304a
parent11fac6778ba2b4fb584262ea798acf9a8b3bb86f (diff)
downloadFreeBSD-src-2628b26a5edabadc373f8e3e63d70dbf449fc99c.zip
FreeBSD-src-2628b26a5edabadc373f8e3e63d70dbf449fc99c.tar.gz
Upgrade these regression tests to track recent changes to `env'.
Approved by: re (blanket `env')
-rw-r--r--tools/regression/usr.bin/env/regress-env.rgdata81
1 files changed, 78 insertions, 3 deletions
diff --git a/tools/regression/usr.bin/env/regress-env.rgdata b/tools/regression/usr.bin/env/regress-env.rgdata
index 04220c6..cc938e2 100644
--- a/tools/regression/usr.bin/env/regress-env.rgdata
+++ b/tools/regression/usr.bin/env/regress-env.rgdata
@@ -217,12 +217,15 @@ gblenv=OUTSIDEVAR=OutsideValue
stderr:[%-testpgm.basename-%]: Only ${VARNAME} expansion is supported, error at: $PATH /bin/sh
[run]
-# Recognize that 'something=value' is a valid utility name if 'something'
-# begins with a '/', since '/' is not allowed in valid environment variables.
+# For a short time `env' was changed to recognize 'something=value' as a
+# valid utility name if 'something' begins with a '/'. However, that was
+# a bad idea, since variable-names with a '/' -- while rare -- are still
+# more blessed by standards than a filename with an '=' in it. So, this
+# test goes back to expecting an error...
[test]
symlink:/bin/echo /tmp/envtest=echo
sb_args:-S/tmp/envtest=echo false
- stdout:false [%-script.pathname-%]
+ $?:1
[run]
# Show interactions between -i (clear environment), and ${VAR} substitution,
@@ -242,3 +245,75 @@ gblenv=OUTSIDEVAR=OutsideValue
stdout:WASPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
stdout:WASTEST=Global-TV-Value
[run]
+
+# Had a bug with ${VAR} expansion if the character before the $ was
+# one of the argument-separator characters. So the first of the
+# following worked, but the second one failed:
+[test]
+ sb_args:-Secho Testv:${TESTV} Scriptname:
+ setenv:TESTV=ab/ba
+ stdout:Testv:ab/ba Scriptname: [%-script.pathname-%]
+[run]
+[test]
+ sb_args:-Secho testV: ${TESTV} scriptname:
+ setenv:TESTV=cd/dc
+ stdout:testV: cd/dc scriptname: [%-script.pathname-%]
+[run]
+
+# A "nothing variable" inside a quoted string should produce a zero-length
+# argument, but if it's outside of quotes then it should result in, well,
+# nothing. Note the tricks we play with [%-script.pathname-%] so that we
+# can supply parameters *to* the script, even though the kernel is always
+# going to stick the script name on as ARG[2] when invoking `env'.
+[test]
+ sb_args:-S/bin/sh [%-script.pathname-%] userDQ: "" SQ: '' scriptname:
+ setenv:TNADA=
+ script:printf "list_args.sh with \$# = $#\n"
+ script:# Process all parameters.
+ script:N=0
+ script:while test $# != 0 ; do
+ script: N=$(($N+1))
+ script: printf "....\$$N = [%3d] '$1'\n" ${#1}
+ script: shift
+ script:done
+ stdout:list_args.sh with $# = 6
+ stdout:....$1 = [ 7] 'userDQ:'
+ stdout:....$2 = [ 0] ''
+ stdout:....$3 = [ 3] 'SQ:'
+ stdout:....$4 = [ 0] ''
+ stdout:....$5 = [ 11] 'scriptname:'
+ stdout:....$6 = [ 16] '/tmp/env-regress'
+[run]
+[test]
+ sb_args:-S/bin/sh [%-script.pathname-%] userB "${TNADA}" scriptname:
+ setenv:TNADA=
+ script:printf "list_args.sh with \$# = $#\n"
+ script:# Process all parameters.
+ script:N=0
+ script:while test $# != 0 ; do
+ script: N=$(($N+1))
+ script: printf "....\$$N = [%3d] '$1'\n" ${#1}
+ script: shift
+ script:done
+ stdout:list_args.sh with $# = 4
+ stdout:....$1 = [ 5] 'userB'
+ stdout:....$2 = [ 0] ''
+ stdout:....$3 = [ 11] 'scriptname:'
+ stdout:....$4 = [ 16] '/tmp/env-regress'
+[run]
+[test]
+ sb_args:-S/bin/sh [%-script.pathname-%] userA ${TNADA} scriptname:
+ setenv:TNADA=
+ script:printf "list_args.sh with \$# = $#\n"
+ script:# Process all parameters.
+ script:N=0
+ script:while test $# != 0 ; do
+ script: N=$(($N+1))
+ script: printf "....\$$N = [%3d] '$1'\n" ${#1}
+ script: shift
+ script:done
+ stdout:list_args.sh with $# = 3
+ stdout:....$1 = [ 5] 'userA'
+ stdout:....$2 = [ 12] ' scriptname:'
+ stdout:....$3 = [ 16] '[%-script.pathname-%]'
+[run]
OpenPOWER on IntegriCloud