16cc00fe2SGarance A Drosehn#- 26cc00fe2SGarance A Drosehn# Copyright (c) 2005 - Garance Alistair Drosehn <gad@FreeBSD.org>. 36cc00fe2SGarance A Drosehn# All rights reserved. 46cc00fe2SGarance A Drosehn# 56cc00fe2SGarance A Drosehn# Redistribution and use in source and binary forms, with or without 66cc00fe2SGarance A Drosehn# modification, are permitted provided that the following conditions 76cc00fe2SGarance A Drosehn# are met: 86cc00fe2SGarance A Drosehn# 1. Redistributions of source code must retain the above copyright 96cc00fe2SGarance A Drosehn# notice, this list of conditions and the following disclaimer. 106cc00fe2SGarance A Drosehn# 2. Redistributions in binary form must reproduce the above copyright 116cc00fe2SGarance A Drosehn# notice, this list of conditions and the following disclaimer in the 126cc00fe2SGarance A Drosehn# documentation and/or other materials provided with the distribution. 136cc00fe2SGarance A Drosehn# 146cc00fe2SGarance A Drosehn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 156cc00fe2SGarance A Drosehn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 166cc00fe2SGarance A Drosehn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 176cc00fe2SGarance A Drosehn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 186cc00fe2SGarance A Drosehn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 196cc00fe2SGarance A Drosehn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 206cc00fe2SGarance A Drosehn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 216cc00fe2SGarance A Drosehn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 226cc00fe2SGarance A Drosehn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 236cc00fe2SGarance A Drosehn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 246cc00fe2SGarance A Drosehn# SUCH DAMAGE. 256cc00fe2SGarance A Drosehn# 266cc00fe2SGarance A Drosehn# 276cc00fe2SGarance A Drosehn 286cc00fe2SGarance A Drosehntestpgm=/usr/bin/env 296cc00fe2SGarance A Drosehngblenv=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin 306cc00fe2SGarance A Drosehngblenv=TESTVAR=Global-TV-Value 316cc00fe2SGarance A Drosehngblenv=OUTSIDEVAR=OutsideValue 326cc00fe2SGarance A Drosehn 336cc00fe2SGarance A Drosehn# These first two tests are testing how well the regression-script itself is 346cc00fe2SGarance A Drosehn# handling environment-variables, as much as testing the `env' program. 356cc00fe2SGarance A Drosehn[test] 366cc00fe2SGarance A Drosehn sb_args:/bin/sh 376cc00fe2SGarance A Drosehn setenv:TESTVAR=a1a 386cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 396cc00fe2SGarance A Drosehn stdout:A-a1a-Z 406cc00fe2SGarance A Drosehn[run] 416cc00fe2SGarance A Drosehn[test] 426cc00fe2SGarance A Drosehn sb_args:-S /bin/sh 436cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 446cc00fe2SGarance A Drosehn stdout:A-Global-TV-Value-Z 456cc00fe2SGarance A Drosehn[run] 466cc00fe2SGarance A Drosehn 476cc00fe2SGarance A Drosehn[test] 486cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=bb22bb /bin/sh 496cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 506cc00fe2SGarance A Drosehn stdout:A-bb22bb-Z 516cc00fe2SGarance A Drosehn[run] 526cc00fe2SGarance A Drosehn[test] 536cc00fe2SGarance A Drosehn sb_args:-S\_TESTVAR=ab22ab\_/bin/sh 546cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 556cc00fe2SGarance A Drosehn stdout:A-ab22ab-Z 566cc00fe2SGarance A Drosehn[run] 576cc00fe2SGarance A Drosehn[test] 586cc00fe2SGarance A Drosehn sb_args:-S\_TESTVAR="abc\_33\_abc"\_/bin/sh 596cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 606cc00fe2SGarance A Drosehn stdout:A-abc 33 abc-Z 616cc00fe2SGarance A Drosehn[run] 626cc00fe2SGarance A Drosehn 636cc00fe2SGarance A Drosehn# First we see that 'sh' can not be found in /usr/sbin, and then 646cc00fe2SGarance A Drosehn# we show that it can be found without changing PATH by using -P 656cc00fe2SGarance A Drosehn# And then show that it can be NOT found by using -P... 666cc00fe2SGarance A Drosehn[test] 676cc00fe2SGarance A Drosehn sb_args:-S sh 686cc00fe2SGarance A Drosehn setenv:PATH=/usr/sbin 696cc00fe2SGarance A Drosehn script:/bin/echo A-${PATH}-Z 706cc00fe2SGarance A Drosehn $?:127 716cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: sh: No such file or directory 726cc00fe2SGarance A Drosehn[run] 736cc00fe2SGarance A Drosehn[test] 746cc00fe2SGarance A Drosehn sb_args:-S -P/bin sh 756cc00fe2SGarance A Drosehn setenv:PATH=/usr/sbin 766cc00fe2SGarance A Drosehn script:/bin/echo A-${PATH}-Z 776cc00fe2SGarance A Drosehn stdout:A-/usr/sbin-Z 786cc00fe2SGarance A Drosehn[run] 796cc00fe2SGarance A Drosehn[test] 806cc00fe2SGarance A Drosehn sb_args:-S -P/sbin:/usr/sbin sh 816cc00fe2SGarance A Drosehn script:/bin/echo A-${PATH}-Z 826cc00fe2SGarance A Drosehn $?:127 836cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: sh: No such file or directory 846cc00fe2SGarance A Drosehn[run] 856cc00fe2SGarance A Drosehn 866cc00fe2SGarance A Drosehn# Hmm. I wonder if -P should always set an 'ENV_PATH' variable? 876cc00fe2SGarance A Drosehn[test] 886cc00fe2SGarance A Drosehn sb_args:-S -P/bin:/usr/bin:${PATH} ENV_PATH=/bin:/usr/bin:${PATH} sh 896cc00fe2SGarance A Drosehn setenv:PATH=/usr/sbin 906cc00fe2SGarance A Drosehn script:/bin/echo A-${PATH}-Z 916cc00fe2SGarance A Drosehn script:/bin/echo B-${ENV_PATH}-Y 926cc00fe2SGarance A Drosehn stdout:A-/usr/sbin-Z 936cc00fe2SGarance A Drosehn stdout:B-/bin:/usr/bin:/usr/sbin-Y 946cc00fe2SGarance A Drosehn[run] 956cc00fe2SGarance A Drosehn 966cc00fe2SGarance A Drosehn# Show that the comment-characters are working, both for where they are 976cc00fe2SGarance A Drosehn# recognized and where they are ignored. 986cc00fe2SGarance A Drosehn[test] 996cc00fe2SGarance A Drosehn sb_args:-STESTVAR="abc44abc" /bin/sh # This is some arbitrary text 1006cc00fe2SGarance A Drosehn user_args:us11er us22er 1016cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z B-$1-Y 1026cc00fe2SGarance A Drosehn stdout:A-abc44abc-Z B-us11er-Y 1036cc00fe2SGarance A Drosehn[run] 1046cc00fe2SGarance A Drosehn[test] 1056cc00fe2SGarance A Drosehn sb_args:-STESTVAR="abc55abc" /bin/sh \c This is some arbitrary text 1066cc00fe2SGarance A Drosehn user_args:us11er us22er 1076cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z B-$1-Y 1086cc00fe2SGarance A Drosehn stdout:A-abc55abc-Z B-us11er-Y 1096cc00fe2SGarance A Drosehn[run] 1106cc00fe2SGarance A Drosehn[test] 1116cc00fe2SGarance A Drosehn sb_args:-STESTVAR=abc#44#abc /bin/sh 1126cc00fe2SGarance A Drosehn user_args:us11er us22er 1136cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z B-$1-Y 1146cc00fe2SGarance A Drosehn stdout:A-abc#44#abc-Z B-us11er-Y 1156cc00fe2SGarance A Drosehn[run] 1166cc00fe2SGarance A Drosehn[test] 1176cc00fe2SGarance A Drosehn sb_args:-STESTVAR='abc\c55\cabc' /bin/sh 1186cc00fe2SGarance A Drosehn user_args:us11er us22er 1196cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z B-$1-Y 1206cc00fe2SGarance A Drosehn stdout:A-abc\c55\cabc-Z B-us11er-Y 1216cc00fe2SGarance A Drosehn[run] 1226cc00fe2SGarance A Drosehn 1236cc00fe2SGarance A Drosehn# Test various aspects of quoted strings 1246cc00fe2SGarance A Drosehn[test] 1256cc00fe2SGarance A Drosehn sb_args:-STESTVAR="abc'def" /bin/sh 1266cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 1276cc00fe2SGarance A Drosehn stdout:A-abc'def-Z 1286cc00fe2SGarance A Drosehn[run] 1296cc00fe2SGarance A Drosehn[test] 1306cc00fe2SGarance A Drosehn sb_args:-STESTVAR='abc"def' /bin/sh 1316cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 1326cc00fe2SGarance A Drosehn stdout:A-abc"def-Z 1336cc00fe2SGarance A Drosehn[run] 1346cc00fe2SGarance A Drosehn[test] 1356cc00fe2SGarance A Drosehn sb_args:-STESTVAR='ab\'cd\'ef' /bin/sh 1366cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 1376cc00fe2SGarance A Drosehn stdout:A-ab'cd'ef-Z 1386cc00fe2SGarance A Drosehn[run] 1396cc00fe2SGarance A Drosehn[test] 1406cc00fe2SGarance A Drosehn sb_args:-STESTVAR='abc\"def\'ghi' /bin/sh 1416cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 1426cc00fe2SGarance A Drosehn stdout:A-abc\"def'ghi-Z 1436cc00fe2SGarance A Drosehn[run] 1446cc00fe2SGarance A Drosehn[test] 1456cc00fe2SGarance A Drosehn sb_args:-STESTVAR='abc''def''ghi' /bin/sh 1466cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-Z 1476cc00fe2SGarance A Drosehn stdout:A-abcdefghi-Z 1486cc00fe2SGarance A Drosehn[run] 1496cc00fe2SGarance A Drosehn[test] 1506cc00fe2SGarance A Drosehn sb_args:-STESTVAR='abc\ndef\nghi' /bin/sh 1516cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1526cc00fe2SGarance A Drosehn stdout:A-abc\ndef\nghi-Z 1536cc00fe2SGarance A Drosehn[run] 1546cc00fe2SGarance A Drosehn[test] 1556cc00fe2SGarance A Drosehn sb_args:-STESTVAR="abc\ndef\nghi" /bin/sh 1566cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1576cc00fe2SGarance A Drosehn stdout:A-abc 1586cc00fe2SGarance A Drosehn stdout:def 1596cc00fe2SGarance A Drosehn stdout:ghi-Z 1606cc00fe2SGarance A Drosehn[run] 1616cc00fe2SGarance A Drosehn[test] 1626cc00fe2SGarance A Drosehn sb_args:-STESTVAR=""\_OTHERVAR=""\_/bin/sh 1636cc00fe2SGarance A Drosehn script:/bin/echo A-${TESTVAR}-M-${OTHERVAR}-Z 1646cc00fe2SGarance A Drosehn stdout:A--M--Z 1656cc00fe2SGarance A Drosehn[run] 1666cc00fe2SGarance A Drosehn[test] 1676cc00fe2SGarance A Drosehn sb_args:-STESTVAR=no-term-"-dq... /bin/sh 1686cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1696cc00fe2SGarance A Drosehn $?:1 1706cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: No terminating quote for string: TESTVAR=no-term-"-dq... /bin/sh 1716cc00fe2SGarance A Drosehn[run] 1726cc00fe2SGarance A Drosehn[test] 1736cc00fe2SGarance A Drosehn sb_args:-STESTVAR=no-term-'-sq... /bin/sh 1746cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1756cc00fe2SGarance A Drosehn $?:1 1766cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: No terminating quote for string: TESTVAR=no-term-'-sq... /bin/sh 1776cc00fe2SGarance A Drosehn[run] 1786cc00fe2SGarance A Drosehn 1796cc00fe2SGarance A Drosehn# Some tests of variable-substitution. 1806cc00fe2SGarance A Drosehn[test] 1816cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=${TEST7} /bin/sh 1826cc00fe2SGarance A Drosehn setenv:TEST7=a23456a 1836cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1846cc00fe2SGarance A Drosehn stdout:A-a23456a-Z 1856cc00fe2SGarance A Drosehn[run] 1866cc00fe2SGarance A Drosehn[test] 1876cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=${TEST8} /bin/sh 1886cc00fe2SGarance A Drosehn setenv:TEST8=b234567b 1896cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1906cc00fe2SGarance A Drosehn stdout:A-b234567b-Z 1916cc00fe2SGarance A Drosehn[run] 1926cc00fe2SGarance A Drosehn[test] 1936cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=${TEST9} /bin/sh 1946cc00fe2SGarance A Drosehn setenv:TEST9=c2345678c 1956cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 1966cc00fe2SGarance A Drosehn stdout:A-c2345678c-Z 1976cc00fe2SGarance A Drosehn[run] 1986cc00fe2SGarance A Drosehn[test] 1996cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=${TEST8}+${TEST9}+${TEST10} /bin/sh 2006cc00fe2SGarance A Drosehn setenv:TEST8=a234567z 2016cc00fe2SGarance A Drosehn setenv:TEST9=a2345678z 2026cc00fe2SGarance A Drosehn setenv:TEST10=a23456789z 2036cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 2046cc00fe2SGarance A Drosehn stdout:A-a234567z+a2345678z+a23456789z-Z 2056cc00fe2SGarance A Drosehn[run] 2066cc00fe2SGarance A Drosehn[test] 2076cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=$* /bin/sh 2086cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 2096cc00fe2SGarance A Drosehn $?:1 2106cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: Only ${VARNAME} expansion is supported, error at: $* /bin/sh 2116cc00fe2SGarance A Drosehn[run] 2126cc00fe2SGarance A Drosehn[test] 2136cc00fe2SGarance A Drosehn sb_args:-S TESTVAR=/usr/bin:$PATH /bin/sh 2146cc00fe2SGarance A Drosehn script:/bin/echo "A-${TESTVAR}-Z" 2156cc00fe2SGarance A Drosehn $?:1 2166cc00fe2SGarance A Drosehn stderr:[%-testpgm.basename-%]: Only ${VARNAME} expansion is supported, error at: $PATH /bin/sh 2176cc00fe2SGarance A Drosehn[run] 2186cc00fe2SGarance A Drosehn 2192c87a19eSGarance A Drosehn# For a short time `env' was changed to recognize 'something=value' as a 2202c87a19eSGarance A Drosehn# valid utility name if 'something' begins with a '/'. However, that was 2212c87a19eSGarance A Drosehn# a bad idea, since variable-names with a '/' -- while rare -- are still 2222c87a19eSGarance A Drosehn# more blessed by standards than a filename with an '=' in it. So, this 2232c87a19eSGarance A Drosehn# test goes back to expecting an error... 2246cc00fe2SGarance A Drosehn[test] 2256cc00fe2SGarance A Drosehn symlink:/bin/echo /tmp/envtest=echo 2266cc00fe2SGarance A Drosehn sb_args:-S/tmp/envtest=echo false 2272c87a19eSGarance A Drosehn $?:1 2286cc00fe2SGarance A Drosehn[run] 2296cc00fe2SGarance A Drosehn 2306cc00fe2SGarance A Drosehn# Show interactions between -i (clear environment), and ${VAR} substitution, 2316cc00fe2SGarance A Drosehn# and that -i will clear the environment at the right point in processing... 2326cc00fe2SGarance A Drosehn[test] 2336cc00fe2SGarance A Drosehn sb_args:-iS PATH=/bin:/usr/bin:/Not WASPATH=${PATH} WASOUT=${OUTSIDEVAR} TESTVAR=SbValue WASTEST=${TESTVAR} /bin/sh 2346cc00fe2SGarance A Drosehn script:/bin/echo "=== set ===" 2356cc00fe2SGarance A Drosehn script:# drop some environment variables that 'sh' itself sets, and 2366cc00fe2SGarance A Drosehn script:# then have 'set' print out all remaining environment variables. 237aad75bd7SJilles Tjoelker script:# (can't unset OPTIND/PWD, so we use grep to get rid of those) 238aad75bd7SJilles Tjoelker script:unset -v IFS PS1 PS2 PS4 PPID 239aad75bd7SJilles Tjoelker script:set | grep -Ev '^(OPTIND|PWD)=' | sort 2406cc00fe2SGarance A Drosehn stdout:=== set === 2416cc00fe2SGarance A Drosehn stdout:PATH=/bin:/usr/bin:/Not 2426cc00fe2SGarance A Drosehn stdout:TESTVAR=SbValue 2436cc00fe2SGarance A Drosehn stdout:WASOUT=OutsideValue 2446cc00fe2SGarance A Drosehn stdout:WASPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin 2456cc00fe2SGarance A Drosehn stdout:WASTEST=Global-TV-Value 2466cc00fe2SGarance A Drosehn[run] 2472c87a19eSGarance A Drosehn 2482c87a19eSGarance A Drosehn# Had a bug with ${VAR} expansion if the character before the $ was 2492c87a19eSGarance A Drosehn# one of the argument-separator characters. So the first of the 2502c87a19eSGarance A Drosehn# following worked, but the second one failed: 2512c87a19eSGarance A Drosehn[test] 2522c87a19eSGarance A Drosehn sb_args:-Secho Testv:${TESTV} Scriptname: 2532c87a19eSGarance A Drosehn setenv:TESTV=ab/ba 2542c87a19eSGarance A Drosehn stdout:Testv:ab/ba Scriptname: [%-script.pathname-%] 2552c87a19eSGarance A Drosehn[run] 2562c87a19eSGarance A Drosehn[test] 2572c87a19eSGarance A Drosehn sb_args:-Secho testV: ${TESTV} scriptname: 2582c87a19eSGarance A Drosehn setenv:TESTV=cd/dc 2592c87a19eSGarance A Drosehn stdout:testV: cd/dc scriptname: [%-script.pathname-%] 2602c87a19eSGarance A Drosehn[run] 2612c87a19eSGarance A Drosehn 2622c87a19eSGarance A Drosehn# A "nothing variable" inside a quoted string should produce a zero-length 2632c87a19eSGarance A Drosehn# argument, but if it's outside of quotes then it should result in, well, 2642c87a19eSGarance A Drosehn# nothing. Note the tricks we play with [%-script.pathname-%] so that we 2652c87a19eSGarance A Drosehn# can supply parameters *to* the script, even though the kernel is always 2662c87a19eSGarance A Drosehn# going to stick the script name on as ARG[2] when invoking `env'. 2672c87a19eSGarance A Drosehn[test] 2682c87a19eSGarance A Drosehn sb_args:-S/bin/sh [%-script.pathname-%] userDQ: "" SQ: '' scriptname: 2692c87a19eSGarance A Drosehn setenv:TNADA= 2702c87a19eSGarance A Drosehn script:printf "list_args.sh with \$# = $#\n" 2712c87a19eSGarance A Drosehn script:# Process all parameters. 2722c87a19eSGarance A Drosehn script:N=0 2732c87a19eSGarance A Drosehn script:while test $# != 0 ; do 2742c87a19eSGarance A Drosehn script: N=$(($N+1)) 2752c87a19eSGarance A Drosehn script: printf "....\$$N = [%3d] '$1'\n" ${#1} 2762c87a19eSGarance A Drosehn script: shift 2772c87a19eSGarance A Drosehn script:done 2782c87a19eSGarance A Drosehn stdout:list_args.sh with $# = 6 2792c87a19eSGarance A Drosehn stdout:....$1 = [ 7] 'userDQ:' 2802c87a19eSGarance A Drosehn stdout:....$2 = [ 0] '' 2812c87a19eSGarance A Drosehn stdout:....$3 = [ 3] 'SQ:' 2822c87a19eSGarance A Drosehn stdout:....$4 = [ 0] '' 2832c87a19eSGarance A Drosehn stdout:....$5 = [ 11] 'scriptname:' 2842c87a19eSGarance A Drosehn stdout:....$6 = [ 16] '/tmp/env-regress' 2852c87a19eSGarance A Drosehn[run] 2862c87a19eSGarance A Drosehn[test] 2872c87a19eSGarance A Drosehn sb_args:-S/bin/sh [%-script.pathname-%] userB "${TNADA}" scriptname: 2882c87a19eSGarance A Drosehn setenv:TNADA= 2892c87a19eSGarance A Drosehn script:printf "list_args.sh with \$# = $#\n" 2902c87a19eSGarance A Drosehn script:# Process all parameters. 2912c87a19eSGarance A Drosehn script:N=0 2922c87a19eSGarance A Drosehn script:while test $# != 0 ; do 2932c87a19eSGarance A Drosehn script: N=$(($N+1)) 2942c87a19eSGarance A Drosehn script: printf "....\$$N = [%3d] '$1'\n" ${#1} 2952c87a19eSGarance A Drosehn script: shift 2962c87a19eSGarance A Drosehn script:done 2972c87a19eSGarance A Drosehn stdout:list_args.sh with $# = 4 2982c87a19eSGarance A Drosehn stdout:....$1 = [ 5] 'userB' 2992c87a19eSGarance A Drosehn stdout:....$2 = [ 0] '' 3002c87a19eSGarance A Drosehn stdout:....$3 = [ 11] 'scriptname:' 3012c87a19eSGarance A Drosehn stdout:....$4 = [ 16] '/tmp/env-regress' 3022c87a19eSGarance A Drosehn[run] 3032c87a19eSGarance A Drosehn[test] 3042c87a19eSGarance A Drosehn sb_args:-S/bin/sh [%-script.pathname-%] userA ${TNADA} scriptname: 3052c87a19eSGarance A Drosehn setenv:TNADA= 3062c87a19eSGarance A Drosehn script:printf "list_args.sh with \$# = $#\n" 3072c87a19eSGarance A Drosehn script:# Process all parameters. 3082c87a19eSGarance A Drosehn script:N=0 3092c87a19eSGarance A Drosehn script:while test $# != 0 ; do 3102c87a19eSGarance A Drosehn script: N=$(($N+1)) 3112c87a19eSGarance A Drosehn script: printf "....\$$N = [%3d] '$1'\n" ${#1} 3122c87a19eSGarance A Drosehn script: shift 3132c87a19eSGarance A Drosehn script:done 3142c87a19eSGarance A Drosehn stdout:list_args.sh with $# = 3 3152c87a19eSGarance A Drosehn stdout:....$1 = [ 5] 'userA' 316e9651b67SGarance A Drosehn stdout:....$2 = [ 11] 'scriptname:' 3172c87a19eSGarance A Drosehn stdout:....$3 = [ 16] '[%-script.pathname-%]' 3182c87a19eSGarance A Drosehn[run] 319e9651b67SGarance A Drosehn[test] 320e9651b67SGarance A Drosehn sb_args:-S/bin/sh [%-script.pathname-%] ${A} ${NB} ${C} ${ND} ${NE} ${F} S: 321e9651b67SGarance A Drosehn setenv:A=A_ThisisAlongstring_A1 322e9651b67SGarance A Drosehn setenv:NB= 323e9651b67SGarance A Drosehn setenv:C=C_ThisisAlongstring_C1 324e9651b67SGarance A Drosehn setenv:ND= 325e9651b67SGarance A Drosehn setenv:NE= 326e9651b67SGarance A Drosehn setenv:F=F_ThisisAlongstring_F1 327e9651b67SGarance A Drosehn script:printf "list_args.sh with \$# = $#\n" 328e9651b67SGarance A Drosehn script:# Process all parameters. 329e9651b67SGarance A Drosehn script:N=0 330e9651b67SGarance A Drosehn script:while test $# != 0 ; do 331e9651b67SGarance A Drosehn script: N=$(($N+1)) 332e9651b67SGarance A Drosehn script: printf "....\$$N = [%3d] '$1'\n" ${#1} 333e9651b67SGarance A Drosehn script: shift 334e9651b67SGarance A Drosehn script:done 335e9651b67SGarance A Drosehn stdout:list_args.sh with $# = 5 336e9651b67SGarance A Drosehn stdout:....$1 = [ 22] 'A_ThisisAlongstring_A1' 337e9651b67SGarance A Drosehn stdout:....$2 = [ 22] 'C_ThisisAlongstring_C1' 338e9651b67SGarance A Drosehn stdout:....$3 = [ 22] 'F_ThisisAlongstring_F1' 339e9651b67SGarance A Drosehn stdout:....$4 = [ 2] 'S:' 340e9651b67SGarance A Drosehn stdout:....$5 = [ 16] '/tmp/env-regress' 341e9651b67SGarance A Drosehn[run] 342e9651b67SGarance A Drosehn[test] 343e9651b67SGarance A Drosehn sb_args:-S/bin/sh [%-script.pathname-%] ${A} ${NB} "${NB}" ${NB} ${C} "${ND}" ${NE} ${F} S: 344e9651b67SGarance A Drosehn setenv:A=A_ThisisAlongstring_A1 345e9651b67SGarance A Drosehn setenv:NB= 346e9651b67SGarance A Drosehn setenv:C=C_ThisisAlongstring_C1 347e9651b67SGarance A Drosehn setenv:ND= 348e9651b67SGarance A Drosehn setenv:NE= 349e9651b67SGarance A Drosehn setenv:F=F_ThisisAlongstring_F1 350e9651b67SGarance A Drosehn script:printf "list_args.sh with \$# = $#\n" 351e9651b67SGarance A Drosehn script:# Process all parameters. 352e9651b67SGarance A Drosehn script:N=0 353e9651b67SGarance A Drosehn script:while test $# != 0 ; do 354e9651b67SGarance A Drosehn script: N=$(($N+1)) 355e9651b67SGarance A Drosehn script: printf "....\$$N = [%3d] '$1'\n" ${#1} 356e9651b67SGarance A Drosehn script: shift 357e9651b67SGarance A Drosehn script:done 358e9651b67SGarance A Drosehn stdout:list_args.sh with $# = 7 359e9651b67SGarance A Drosehn stdout:....$1 = [ 22] 'A_ThisisAlongstring_A1' 360e9651b67SGarance A Drosehn stdout:....$2 = [ 0] '' 361e9651b67SGarance A Drosehn stdout:....$3 = [ 22] 'C_ThisisAlongstring_C1' 362e9651b67SGarance A Drosehn stdout:....$4 = [ 0] '' 363e9651b67SGarance A Drosehn stdout:....$5 = [ 22] 'F_ThisisAlongstring_F1' 364e9651b67SGarance A Drosehn stdout:....$6 = [ 2] 'S:' 365e9651b67SGarance A Drosehn stdout:....$7 = [ 16] '/tmp/env-regress' 366e9651b67SGarance A Drosehn[run] 367e9651b67SGarance A Drosehn 368e9651b67SGarance A Drosehn[test] 369e9651b67SGarance A Drosehn sb_args:-S/bin/echo ${A} ${B} ${C} ${D} ScriptName: 370e9651b67SGarance A Drosehn setenv:A=A_ThisisAlongstring_A1 371e9651b67SGarance A Drosehn setenv:B=B_ThisisAlongstring_B1 372e9651b67SGarance A Drosehn setenv:C=C_ThisisAlongstring_C1 373e9651b67SGarance A Drosehn setenv:D=D_ThisisAlongstring_D1 374e9651b67SGarance A Drosehn stdout:A_ThisisAlongstring_A1 B_ThisisAlongstring_B1 C_ThisisAlongstring_C1 D_ThisisAlongstring_D1 ScriptName: [%-script.pathname-%] 375e9651b67SGarance A Drosehn[run] 376e9651b67SGarance A Drosehn[test] 377e9651b67SGarance A Drosehn sb_args:-S/bin/echo ${A} "${B}" ${C} "${D}" ScriptName: 378e9651b67SGarance A Drosehn setenv:A=A_ThisisAlongstring_A1 379e9651b67SGarance A Drosehn setenv:B=B_ThisisAlongstring_B1 380e9651b67SGarance A Drosehn setenv:C=C_ThisisAlongstring_C1 381e9651b67SGarance A Drosehn setenv:D=D_ThisisAlongstring_D1 382e9651b67SGarance A Drosehn stdout:A_ThisisAlongstring_A1 B_ThisisAlongstring_B1 C_ThisisAlongstring_C1 D_ThisisAlongstring_D1 ScriptName: [%-script.pathname-%] 383e9651b67SGarance A Drosehn[run] 3846ab1d4d9SJilles Tjoelker 3856ab1d4d9SJilles Tjoelker[test] 3866ab1d4d9SJilles Tjoelker sb_args:sh 3876ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -S '\c' >/dev/null 3886ab1d4d9SJilles Tjoelker[run] 3896ab1d4d9SJilles Tjoelker[test] 3906ab1d4d9SJilles Tjoelker sb_args:sh 3916ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -S'\c' >/dev/null 3926ab1d4d9SJilles Tjoelker[run] 3936ab1d4d9SJilles Tjoelker[test] 3946ab1d4d9SJilles Tjoelker sb_args:sh 3956ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -u foo -S '\c' >/dev/null 3966ab1d4d9SJilles Tjoelker[run] 3976ab1d4d9SJilles Tjoelker[test] 3986ab1d4d9SJilles Tjoelker sb_args:sh 3996ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -u foo -S'\c' >/dev/null 4006ab1d4d9SJilles Tjoelker[run] 4016ab1d4d9SJilles Tjoelker[test] 4026ab1d4d9SJilles Tjoelker sb_args:sh 4036ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -S '-u bar \c' >/dev/null 4046ab1d4d9SJilles Tjoelker[run] 4056ab1d4d9SJilles Tjoelker[test] 4066ab1d4d9SJilles Tjoelker sb_args:sh 4076ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -S'-u bar \c' >/dev/null 4086ab1d4d9SJilles Tjoelker[run] 4096ab1d4d9SJilles Tjoelker[test] 4106ab1d4d9SJilles Tjoelker sb_args:sh 4116ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -u foo -S '-u bar \c' >/dev/null 4126ab1d4d9SJilles Tjoelker[run] 4136ab1d4d9SJilles Tjoelker[test] 4146ab1d4d9SJilles Tjoelker sb_args:sh 4156ab1d4d9SJilles Tjoelker script:[%-testpgm.pathname-%] -u foo -S'-u bar \c' >/dev/null 4166ab1d4d9SJilles Tjoelker[run] 417