mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-08 21:00:48 +02:00
bash-3.1 remove leftover and stray files
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
export THIS_SH PATH
|
||||
|
||||
rm -f /tmp/xx
|
||||
|
||||
/bin/sh "$@"
|
||||
@@ -1,9 +0,0 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
export THIS_SH PATH
|
||||
|
||||
rm -f /tmp/xx
|
||||
|
||||
/bin/sh "$@"
|
||||
@@ -1,190 +0,0 @@
|
||||
|
||||
./array.tests: line 15: syntax error near unexpected token `&'
|
||||
./array.tests: line 15: `test=(first & second)'
|
||||
1
|
||||
abcde
|
||||
abcde
|
||||
abcde bdef
|
||||
abcde bdef
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -a a='([0]="abcde" [1]="" [2]="bdef")'
|
||||
declare -a b='()'
|
||||
declare -ar c='()'
|
||||
abcde bdef
|
||||
abcde bdef
|
||||
abcde
|
||||
abcde
|
||||
abcde
|
||||
|
||||
bdef
|
||||
hello world
|
||||
11
|
||||
3
|
||||
bdef hello world test expression
|
||||
./array.tests: line 74: readonly: `a[5]': not a valid identifier
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -ar c='()'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -ar c='()'
|
||||
readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
readonly -a c='()'
|
||||
a test
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
declare -a d='([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
|
||||
declare -a e='([0]="test")'
|
||||
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
|
||||
./array.tests: line 98: a: readonly variable
|
||||
./array.tests: line 100: b[]: bad array subscript
|
||||
./array.tests: line 101: b[*]: bad array subscript
|
||||
./array.tests: line 102: ${b[ ]}: bad substitution
|
||||
./array.tests: line 104: c[-2]: bad array subscript
|
||||
./array.tests: line 105: c: bad array subscript
|
||||
|
||||
./array.tests: line 107: d[7]: cannot assign list to array member
|
||||
./array.tests: line 109: []=abcde: bad array subscript
|
||||
./array.tests: line 109: [*]=last: cannot assign to non-numeric index
|
||||
./array.tests: line 109: [-65]=negative: bad array subscript
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
declare -a d='([1]="test test")'
|
||||
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
|
||||
./array.tests: line 117: unset: ps1: not an array variable
|
||||
./array.tests: line 121: declare: c: cannot destroy array variables in this way
|
||||
this of
|
||||
this is a test of read using arrays
|
||||
this test
|
||||
this is a test of arrays
|
||||
declare -a BASH_ARGC='()'
|
||||
declare -a BASH_ARGV='()'
|
||||
declare -a BASH_LINENO='([0]="0")'
|
||||
declare -a BASH_SOURCE='([0]="./array.tests")'
|
||||
declare -a DIRSTACK='()'
|
||||
declare -a FUNCNAME='([0]="main")'
|
||||
declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")'
|
||||
declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
|
||||
declare -ar c='()'
|
||||
declare -a d='([1]="test test")'
|
||||
declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
|
||||
declare -a rv='([0]="this" [1]="is" [2]="a" [3]="test" [4]="of" [5]="read" [6]="using" [7]="arrays")'
|
||||
abde
|
||||
abde
|
||||
bbb
|
||||
efgh
|
||||
wxyz
|
||||
wxyz
|
||||
./array.tests
|
||||
a
|
||||
b c
|
||||
d
|
||||
e f g
|
||||
h
|
||||
./array.tests
|
||||
a
|
||||
b c
|
||||
d
|
||||
e f g
|
||||
h
|
||||
/bin /usr/bin /usr/ucb /usr/local/bin . /sbin /usr/sbin
|
||||
bin bin ucb bin . sbin sbin
|
||||
bin
|
||||
/ / / / / /
|
||||
/
|
||||
argv[1] = <bin>
|
||||
argv[1] = </>
|
||||
argv[1] = <sbin>
|
||||
argv[1] = </>
|
||||
\bin \usr/bin \usr/ucb \usr/local/bin . \sbin \usr/sbin
|
||||
\bin \usr\bin \usr\ucb \usr\local\bin . \sbin \usr\sbin
|
||||
\bin \usr\bin \usr\ucb \usr\local\bin . \sbin \usr\sbin
|
||||
4 -- 4
|
||||
7 -- 7
|
||||
55
|
||||
49
|
||||
6 -- 6
|
||||
42 14 44
|
||||
grep [ 123 ] *
|
||||
6 7 9
|
||||
6 7 9 5
|
||||
length = 3
|
||||
value = new1 new2 new3
|
||||
./array.tests: line 237: narray: unbound variable
|
||||
|
||||
a b c d e f g
|
||||
for case if then else
|
||||
<> < > !
|
||||
12 14 16 18 20
|
||||
4414758999202
|
||||
aaa bbb
|
||||
./array.tests: line 277: syntax error near unexpected token `<>'
|
||||
./array.tests: line 277: `metas=( <> < > ! )'
|
||||
./array.tests: line 278: syntax error near unexpected token `<>'
|
||||
./array.tests: line 278: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
|
||||
abc 3
|
||||
case 4
|
||||
abc case if then else 5
|
||||
abc case if then else 5
|
||||
0
|
||||
case 4
|
||||
case if then else 5
|
||||
case if then else 5
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0>
|
||||
argv[2] = <1>
|
||||
argv[3] = <4>
|
||||
argv[4] = <10>
|
||||
argv[1] = <0 1 4 10>
|
||||
include null element -- expect one
|
||||
one
|
||||
include unset element -- expect three five
|
||||
three five
|
||||
start at unset element -- expect five seven
|
||||
five seven
|
||||
too many elements -- expect three five seven
|
||||
three five seven
|
||||
positive offset - expect five seven
|
||||
five seven
|
||||
negative offset to unset element - expect seven
|
||||
seven
|
||||
positive offset 2 - expect seven
|
||||
seven
|
||||
negative offset 2 - expect seven
|
||||
seven
|
||||
out-of-range offset
|
||||
|
||||
e
|
||||
4
|
||||
1 4 7 10
|
||||
'b
|
||||
b c
|
||||
$0
|
||||
t
|
||||
[3]=abcde r s t u v
|
||||
e
|
||||
9
|
||||
@@ -1,399 +0,0 @@
|
||||
# this is needed so that the bad assignments (b[]=bcde, for example) do not
|
||||
# cause fatal shell errors when in posix mode
|
||||
set +o posix
|
||||
|
||||
set +a
|
||||
# The calls to egrep -v are to filter out builtin array variables that are
|
||||
# automatically set and possibly contain values that vary.
|
||||
|
||||
# first make sure we handle the basics
|
||||
x=()
|
||||
echo ${x[@]}
|
||||
unset x
|
||||
|
||||
# this should be an error
|
||||
test=(first & second)
|
||||
echo $?
|
||||
unset test
|
||||
|
||||
# make sure declare -a converts an existing variable to an array
|
||||
unset a
|
||||
a=abcde
|
||||
declare -a a
|
||||
echo ${a[0]}
|
||||
|
||||
unset a
|
||||
a=abcde
|
||||
a[2]=bdef
|
||||
|
||||
unset b
|
||||
declare -a b[256]
|
||||
|
||||
unset c[2]
|
||||
unset c[*]
|
||||
|
||||
a[1]=
|
||||
|
||||
_ENV=/bin/true
|
||||
x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}
|
||||
|
||||
declare -r c[100]
|
||||
|
||||
echo ${a[0]} ${a[4]}
|
||||
echo ${a[@]}
|
||||
|
||||
echo ${a[*]}
|
||||
|
||||
# this should print out values, too
|
||||
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
|
||||
unset a[7]
|
||||
echo ${a[*]}
|
||||
|
||||
unset a[4]
|
||||
echo ${a[*]}
|
||||
|
||||
echo ${a}
|
||||
echo "${a}"
|
||||
echo $a
|
||||
|
||||
unset a[0]
|
||||
echo ${a}
|
||||
|
||||
echo ${a[@]}
|
||||
|
||||
a[5]="hello world"
|
||||
echo ${a[5]}
|
||||
echo ${#a[5]}
|
||||
|
||||
echo ${#a[@]}
|
||||
|
||||
a[4+5/2]="test expression"
|
||||
echo ${a[@]}
|
||||
|
||||
readonly a[5]
|
||||
readonly a
|
||||
# these two lines should output `declare' commands
|
||||
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
# this line should output `readonly' commands, even for arrays
|
||||
set -o posix
|
||||
readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
set +o posix
|
||||
|
||||
declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
|
||||
d[9]="ninth element"
|
||||
|
||||
declare -a e[10]=test # this works in post-bash-2.05 versions
|
||||
declare -a e[10]='(test)'
|
||||
|
||||
pass=/etc/passwd
|
||||
declare -a f='("${d[@]}")'
|
||||
b=([0]=this [1]=is [2]=a [3]=test [4]="$PS1" [5]=$pass)
|
||||
|
||||
echo ${b[@]:2:3}
|
||||
|
||||
declare -pa | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
|
||||
a[3]="this is a test"
|
||||
|
||||
b[]=bcde
|
||||
b[*]=aaa
|
||||
echo ${b[ ]}
|
||||
|
||||
c[-2]=4
|
||||
echo ${c[-4]}
|
||||
|
||||
d[7]=(abdedfegeee)
|
||||
|
||||
d=([]=abcde [1]="test test" [*]=last [-65]=negative )
|
||||
|
||||
unset d[12]
|
||||
unset e[*]
|
||||
|
||||
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
|
||||
ps1='hello'
|
||||
unset ps1[2]
|
||||
unset ${ps1[2]}
|
||||
|
||||
declare +a ps1
|
||||
declare +a c
|
||||
|
||||
# the prompt should not print when using a here doc
|
||||
read -p "array test: " -a rv <<!
|
||||
this is a test of read using arrays
|
||||
!
|
||||
|
||||
echo ${rv[0]} ${rv[4]}
|
||||
echo ${rv[@]}
|
||||
|
||||
# the variable should be converted to an array when `read -a' is done
|
||||
vv=1
|
||||
read -a vv <<!
|
||||
this is a test of arrays
|
||||
!
|
||||
echo ${vv[0]} ${vv[3]}
|
||||
echo ${vv[@]}
|
||||
unset vv
|
||||
|
||||
declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
|
||||
|
||||
export rv
|
||||
#set
|
||||
|
||||
x[4]=bbb
|
||||
x=abde
|
||||
echo $x
|
||||
echo ${x[0]}
|
||||
echo ${x[4]}
|
||||
echo efgh | ( read x[1] ; echo ${x[1]} )
|
||||
echo wxyz | ( declare -a x ; read x ; echo $x ; echo ${x[0]} )
|
||||
|
||||
# Make sure that arrays can be used to save the positional paramters verbatim
|
||||
set -- a 'b c' d 'e f g' h
|
||||
|
||||
ARGV=( [0]=$0 "$@" )
|
||||
|
||||
for z in "${ARGV[@]}"
|
||||
do
|
||||
echo "$z"
|
||||
done
|
||||
|
||||
echo "$0"
|
||||
for z in "$@"
|
||||
do
|
||||
echo "$z"
|
||||
done
|
||||
|
||||
# do various pattern removal and length tests
|
||||
XPATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:.:/sbin:/usr/sbin
|
||||
|
||||
xpath=( $( IFS=: ; echo $XPATH ) )
|
||||
|
||||
echo ${xpath[@]}
|
||||
echo ${xpath[@]##*/}
|
||||
echo ${xpath[0]##*/}
|
||||
echo ${xpath[@]%%[!/]*}
|
||||
echo ${xpath[0]%%[!/]*}
|
||||
recho ${xpath##*/}
|
||||
recho ${xpath%%[!/]*}
|
||||
recho ${xpath[5]##*/}
|
||||
recho ${xpath[5]%%[!/]*}
|
||||
|
||||
# let's try to make it a DOS-style path
|
||||
|
||||
zecho "${xpath[@]/\//\\}"
|
||||
zecho "${xpath[@]//\//\\}"
|
||||
zecho "${xpath[@]//[\/]/\\}"
|
||||
|
||||
# length of the first element of the array, since array without subscript
|
||||
# is equivalent to referencing first element
|
||||
echo ${#xpath} -- ${#xpath[0]}
|
||||
|
||||
# number of elements in the array
|
||||
nelem=${#xpath[@]}
|
||||
echo ${#xpath[@]} -- $nelem
|
||||
|
||||
# total length of all elements in the array, including space separators
|
||||
xx="${xpath[*]}"
|
||||
echo ${#xx}
|
||||
|
||||
# total length of all elements in the array
|
||||
xx=$( IFS='' ; echo "${xpath[*]}" )
|
||||
echo ${#xx}
|
||||
|
||||
unset xpath[nelem-1]
|
||||
|
||||
nelem=${#xpath[@]}
|
||||
echo ${#xpath[@]} -- $nelem
|
||||
|
||||
# arrays and things that look like index assignments
|
||||
array=(42 [1]=14 [2]=44)
|
||||
|
||||
array2=(grep [ 123 ] \*)
|
||||
|
||||
echo ${array[@]}
|
||||
echo "${array2[@]}"
|
||||
|
||||
# arrays and implicit arithmetic evaluation
|
||||
declare -i -a iarray
|
||||
|
||||
iarray=( 2+4 1+6 7+2 )
|
||||
echo ${iarray[@]}
|
||||
|
||||
iarray[4]=4+1
|
||||
echo ${iarray[@]}
|
||||
|
||||
# make sure assignment using the compound assignment syntax removes all
|
||||
# of the old elements from the array value
|
||||
barray=(old1 old2 old3 old4 old5)
|
||||
barray=(new1 new2 new3)
|
||||
echo "length = ${#barray[@]}"
|
||||
echo "value = ${barray[*]}"
|
||||
|
||||
# make sure the array code behaves correctly with respect to unset variables
|
||||
set -u
|
||||
( echo ${#narray[4]} )
|
||||
|
||||
${THIS_SH} ./array1.sub
|
||||
${THIS_SH} ./array2.sub
|
||||
|
||||
# some old bugs and ksh93 compatibility tests
|
||||
${THIS_SH} ./array3.sub
|
||||
|
||||
set +u
|
||||
cd /tmp
|
||||
|
||||
touch 1=bar
|
||||
foo=([10]="bar")
|
||||
echo ${foo[0]}
|
||||
rm 1=bar
|
||||
|
||||
foo=(a b c d e f g)
|
||||
echo ${foo[@]}
|
||||
|
||||
# quoted reserved words are ok
|
||||
foo=(\for \case \if \then \else)
|
||||
echo ${foo[@]}
|
||||
|
||||
# quoted metacharacters are ok
|
||||
foo=( [1]='<>' [2]='<' [3]='>' [4]='!' )
|
||||
echo ${foo[@]}
|
||||
|
||||
# numbers are just words when not in a redirection context
|
||||
foo=( 12 14 16 18 20 )
|
||||
echo ${foo[@]}
|
||||
|
||||
foo=( 4414758999202 )
|
||||
echo ${foo[@]}
|
||||
|
||||
# this was a bug in all versions of bash 2.x up to and including bash-2.04
|
||||
declare -a ddd=(aaa
|
||||
bbb)
|
||||
echo ${ddd[@]}
|
||||
|
||||
# errors until post-bash-2.05a; now reserved words are OK
|
||||
foo=(a b c for case if then else)
|
||||
|
||||
foo=(for case if then else)
|
||||
|
||||
# errors
|
||||
metas=( <> < > ! )
|
||||
metas=( [1]=<> [2]=< [3]=> [4]=! )
|
||||
|
||||
# various expansions that didn't really work right until post-bash-2.04
|
||||
foo='abc'
|
||||
echo ${foo[0]} ${#foo[0]}
|
||||
echo ${foo[1]} ${#foo[1]}
|
||||
echo ${foo[@]} ${#foo[@]}
|
||||
echo ${foo[*]} ${#foo[*]}
|
||||
|
||||
foo=''
|
||||
echo ${foo[0]} ${#foo[0]}
|
||||
echo ${foo[1]} ${#foo[1]}
|
||||
echo ${foo[@]} ${#foo[@]}
|
||||
echo ${foo[*]} ${#foo[*]}
|
||||
|
||||
# new expansions added after bash-2.05b
|
||||
x[0]=zero
|
||||
x[1]=one
|
||||
x[4]=four
|
||||
x[10]=ten
|
||||
|
||||
recho ${!x[@]}
|
||||
recho "${!x[@]}"
|
||||
recho ${!x[*]}
|
||||
recho "${!x[*]}"
|
||||
|
||||
# sparse array tests for code fixed in bash-3.0
|
||||
unset av
|
||||
av[1]='one'
|
||||
av[2]=''
|
||||
|
||||
av[3]=three
|
||||
av[5]=five
|
||||
av[7]=seven
|
||||
|
||||
echo include null element -- expect one
|
||||
echo ${av[@]:1:2} # what happens when we include a null element?
|
||||
echo include unset element -- expect three five
|
||||
echo ${av[@]:3:2} # what happens when we include an unset element?
|
||||
echo start at unset element -- expect five seven
|
||||
echo ${av[@]:4:2} # what happens when we start at an unset element?
|
||||
|
||||
echo too many elements -- expect three five seven
|
||||
echo ${av[@]:3:5} # how about too many elements?
|
||||
|
||||
echo positive offset - expect five seven
|
||||
echo ${av[@]:5:2}
|
||||
echo negative offset to unset element - expect seven
|
||||
echo ${av[@]: -2:2}
|
||||
|
||||
echo positive offset 2 - expect seven
|
||||
echo ${av[@]: 6:2}
|
||||
echo negative offset 2 - expect seven
|
||||
echo ${av[@]: -1:2}
|
||||
|
||||
echo out-of-range offset
|
||||
echo ${av[@]:12}
|
||||
|
||||
# parsing problems and other inconsistencies not fixed until post bash-3.0
|
||||
unset x
|
||||
declare -a x=(')' $$)
|
||||
[ ${x[1]} -eq $$ ] || echo bad
|
||||
|
||||
unset x
|
||||
declare -a x=(a b c d e)
|
||||
echo ${x[4]}
|
||||
|
||||
z=([1]=one [4]=four [7]=seven [10]=ten)
|
||||
|
||||
echo ${#z[@]}
|
||||
|
||||
echo ${!z[@]}
|
||||
|
||||
unset x
|
||||
declare -a x=(a \'b c\')
|
||||
|
||||
echo "${x[1]}"
|
||||
|
||||
unset x
|
||||
declare -a x=(a 'b c')
|
||||
|
||||
echo "${x[1]}"
|
||||
|
||||
unset x
|
||||
declare -a x=($0)
|
||||
[ "${x[@]}" = $0 ] || echo double expansion of \$0
|
||||
declare -a x=(\$0)
|
||||
echo "${x[@]}"
|
||||
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
mkdir $TMPDIR/bash-test-$$
|
||||
cd $TMPDIR/bash-test-$$
|
||||
|
||||
trap "cd / ; rm -rf $TMPDIR/bash-test/$$" 0 1 2 3 6 15
|
||||
|
||||
touch '[3]=abcde'
|
||||
|
||||
touch r s t u v
|
||||
|
||||
declare -a x=(*)
|
||||
|
||||
echo ${x[3]}
|
||||
echo ${x[@]}
|
||||
|
||||
unset x
|
||||
x=(a b c d e)
|
||||
|
||||
echo ${x[*]: -1}
|
||||
|
||||
unset x[4]
|
||||
unset x[2]
|
||||
|
||||
x[9]='9'
|
||||
|
||||
echo ${x[*]: -1}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
echo ff{c,b,a}
|
||||
echo f{d,e,f}g
|
||||
echo {l,n,m}xyz
|
||||
echo {abc\,def}
|
||||
echo {abc}
|
||||
|
||||
echo \{a,b,c,d,e}
|
||||
echo {x,y,\{a,b,c}}
|
||||
echo {x\,y,\{abc\},trie}
|
||||
|
||||
echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
|
||||
|
||||
echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
eval echo XXXX\{`echo a b c | tr ' ' ','`\}
|
||||
|
||||
echo {}
|
||||
echo { }
|
||||
echo }
|
||||
echo {
|
||||
echo abcd{efgh
|
||||
|
||||
echo foo {1,2} bar
|
||||
echo `zecho foo {1,2} bar`
|
||||
echo $(zecho foo {1,2} bar)
|
||||
|
||||
var=baz
|
||||
varx=vx
|
||||
vary=vy
|
||||
|
||||
echo foo{bar,${var}.}
|
||||
echo foo{bar,${var}}
|
||||
|
||||
echo "${var}"{x,y}
|
||||
echo $var{x,y}
|
||||
echo ${var}{x,y}
|
||||
|
||||
unset var varx vary
|
||||
|
||||
# new sequence brace operators
|
||||
echo {1..10}
|
||||
|
||||
# this doesn't work yet
|
||||
echo {0..10,braces}
|
||||
# but this does
|
||||
echo {{0..10},braces}
|
||||
echo x{{0..10},braces}y
|
||||
|
||||
echo {3..3}
|
||||
echo x{3..3}y
|
||||
echo {10..1}
|
||||
echo {10..1}y
|
||||
echo x{10..1}y
|
||||
|
||||
echo {a..f}
|
||||
echo {f..a}
|
||||
|
||||
echo {a..A}
|
||||
echo {A..a}
|
||||
|
||||
echo {f..f}
|
||||
|
||||
# mixes are incorrectly-formed brace expansions
|
||||
echo {1..f}
|
||||
echo {f..1}
|
||||
|
||||
echo 0{1..9} {10..20}
|
||||
|
||||
# do negative numbers work?
|
||||
echo {-1..-10}
|
||||
echo {-20..0}
|
||||
@@ -1,72 +0,0 @@
|
||||
tf is a function
|
||||
tf ()
|
||||
{
|
||||
echo this is ${0##*/} >/dev/null;
|
||||
echo a | cat - >/dev/null;
|
||||
test -f ${0##*/} && echo ${0##*/} is a regular file;
|
||||
test -d ${0##*/} || echo ${0##*/} is not a directory;
|
||||
echo a;
|
||||
echo b;
|
||||
echo c;
|
||||
echo background >/dev/null & ( exit 1 );
|
||||
echo $?;
|
||||
{
|
||||
echo a
|
||||
};
|
||||
i=0;
|
||||
while (( " i < 3 " )); do
|
||||
test -r /dev/fd/$i;
|
||||
i=$(( i + 1 ));
|
||||
done;
|
||||
[[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops >/dev/null;
|
||||
for name in $( echo 1 2 3 );
|
||||
do
|
||||
test -r /dev/fd/$name;
|
||||
done;
|
||||
if [[ -r /dev/fd/0 && -w /dev/fd/1 ]]; then
|
||||
echo ok >/dev/null;
|
||||
else
|
||||
if (( " 7 > 40 " )); then
|
||||
echo oops;
|
||||
else
|
||||
echo done;
|
||||
fi;
|
||||
fi >/dev/null;
|
||||
case $PATH in
|
||||
*$PWD*)
|
||||
echo \$PWD in \$PATH
|
||||
;;
|
||||
*)
|
||||
echo \$PWD not in \$PATH
|
||||
;;
|
||||
esac >/dev/null;
|
||||
while false; do
|
||||
echo z;
|
||||
done >/dev/null;
|
||||
until true; do
|
||||
echo z;
|
||||
done >/dev/null;
|
||||
echo \&\|'()' \{ echo abcde \; \};
|
||||
eval fu\%nc'()' \{ echo abcde \; \};
|
||||
type fu\%nc
|
||||
}
|
||||
tf2 is a function
|
||||
tf2 ()
|
||||
{
|
||||
( {
|
||||
time -p echo a | cat - >/dev/null
|
||||
} ) 2>&1
|
||||
}
|
||||
cprint.tests is a regular file
|
||||
cprint.tests is not a directory
|
||||
a
|
||||
b
|
||||
c
|
||||
1
|
||||
a
|
||||
&|() { echo abcde ; }
|
||||
fu%nc is a function
|
||||
fu%nc ()
|
||||
{
|
||||
echo abcde
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
#!../bash
|
||||
#
|
||||
# Test correct functioning bash debug support not via the bashdb
|
||||
# debugger but merely by printing via print_trap()
|
||||
# $Id: dbg-support.tests,v 1.13 2003/02/17 22:02:25 rockyb Exp $
|
||||
shopt -s extdebug
|
||||
print_debug_trap() {
|
||||
echo "debug lineno: $1 ${FUNCNAME[1]}"
|
||||
return
|
||||
}
|
||||
|
||||
print_return_trap() {
|
||||
echo "return lineno: $1 ${FUNCNAME[1]}"
|
||||
return
|
||||
}
|
||||
|
||||
fn1() {
|
||||
echo "LINENO $LINENO"
|
||||
echo "LINENO $LINENO"
|
||||
echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
|
||||
echo "FUNCNAME[0]" ${FUNCNAME[0]}
|
||||
echo `caller`
|
||||
echo `caller 0`
|
||||
echo `caller 1`
|
||||
echo `caller foo`
|
||||
}
|
||||
|
||||
fn2() {
|
||||
echo "fn2 here. Calling fn1..."
|
||||
fn1
|
||||
}
|
||||
|
||||
fn3() {
|
||||
echo "LINENO $LINENO"
|
||||
echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
|
||||
|
||||
# Print a stack trace
|
||||
declare -i n
|
||||
n=${#FUNCNAME[@]}
|
||||
for (( i=0 ; (( i < $n )) ; i++ )) ; do
|
||||
local -i j=i+1
|
||||
[ $j -eq $n ] && j=i # main()'s file is the same as the first caller
|
||||
echo "${FUNCNAME[$i]} called from file " \
|
||||
"\`${BASH_SOURCE[$j]}' at line ${BASH_LINENO[$j]}"
|
||||
done
|
||||
source ./dbg-support.sub
|
||||
}
|
||||
|
||||
fn4() {
|
||||
echo "fn4 here. Calling fn3..."
|
||||
fn3
|
||||
}
|
||||
|
||||
|
||||
#!../bash
|
||||
#
|
||||
# Test of support for debugging facilities in bash
|
||||
#
|
||||
# Test debugger set option fntrace - set on. Not in vanilla Bash 2.05
|
||||
#
|
||||
set -o functrace
|
||||
trap 'print_debug_trap $LINENO' DEBUG
|
||||
trap 'print_return_trap $LINENO' RETURN
|
||||
|
||||
# Funcname is now an array, but you still can't see it outside a function
|
||||
echo "FUNCNAME" ${FUNCNAME[0]:-main}
|
||||
|
||||
# We should trace into the below.
|
||||
# Start easy with a simple function.
|
||||
fn1
|
||||
fn2
|
||||
fn3
|
||||
source ./dbg-support.sub
|
||||
|
||||
# Test debugger set option fntrace - set off
|
||||
set +T
|
||||
|
||||
# We should not trace into this.
|
||||
fn1
|
||||
fn2
|
||||
fn3
|
||||
fn4
|
||||
source ./dbg-support.sub
|
||||
|
||||
# Another way to say: set -o fntrace
|
||||
set -T
|
||||
|
||||
# We should trace into this.
|
||||
source ./dbg-support.sub
|
||||
set +T
|
||||
|
||||
# Test that the line numbers in the presence of conditionals are correct.
|
||||
for (( i=0 ; (( i <= 2 )) ; i++ )) ; do
|
||||
if [ $i -eq 2 ] ; then
|
||||
echo "Hit 2"
|
||||
fi
|
||||
j=4
|
||||
done
|
||||
|
||||
#
|
||||
# Check line numbers in command substitution
|
||||
#
|
||||
echo $(sourced_fn)
|
||||
echo `sourced_fn`
|
||||
x=$((sourced_fn))
|
||||
x={ sourced_fn }
|
||||
|
||||
# Make sure we step into sourced_fn as a comand when we request to do so.
|
||||
# Vanilla bash 2.0 doesn't do.
|
||||
set -o functrace
|
||||
x={ sourced_fn }
|
||||
|
||||
# Should see line number of xyzzy below. Vanilla bash 2.05b doesn't do
|
||||
case xyzzy in
|
||||
a )
|
||||
x=5
|
||||
;;
|
||||
xyzz? )
|
||||
case 3 in
|
||||
2 )
|
||||
x=6 ;;
|
||||
3 )
|
||||
echo "got it" ;;
|
||||
* ) echo "no good" ;;
|
||||
esac
|
||||
;;
|
||||
* )
|
||||
esac
|
||||
|
||||
# Should see line numbers for initial for lines.
|
||||
for i in 0 1 ; do
|
||||
for j in 3 4 ; do
|
||||
((x=i+j))
|
||||
done
|
||||
done
|
||||
#;;; Local Variables: ***
|
||||
#;;; mode:shell-script ***
|
||||
#;;; eval: (sh-set-shell "bash") ***
|
||||
#;;; End: ***
|
||||
@@ -1,226 +0,0 @@
|
||||
# first, let's start with the basics
|
||||
|
||||
recho "$@"
|
||||
recho "$*"
|
||||
|
||||
recho $@
|
||||
recho $*
|
||||
|
||||
set a b
|
||||
|
||||
recho "$*"
|
||||
|
||||
# If IFS is null, the parameters are joined without separators
|
||||
IFS=''
|
||||
recho "$*"
|
||||
|
||||
# If IFS is unset, the parameters are separated by spaces
|
||||
unset IFS
|
||||
recho "${*}"
|
||||
|
||||
recho "$@"
|
||||
recho $@
|
||||
|
||||
IFS='/'
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set ${*}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set ${@}
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# according to POSIX.2, unquoted $* should expand to multiple words if
|
||||
# $IFS is null, just like unquoted $@
|
||||
IFS=''
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# if IFS is unset, the individual positional parameters are split on
|
||||
# " \t\n" if $* or $@ are unquoted
|
||||
unset IFS
|
||||
set bob 'tom dick harry' joe
|
||||
set $*
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set $@
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# but not for "$@" or "$*"
|
||||
set bob 'tom dick harry' joe
|
||||
set "$*"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
set bob 'tom dick harry' joe
|
||||
set "$@"
|
||||
recho $#
|
||||
recho $1
|
||||
recho $2
|
||||
recho $3
|
||||
|
||||
# POSIX.2 says these should both expand the positional parameters
|
||||
# to multiple words
|
||||
set a b c d e
|
||||
IFS=""
|
||||
recho $@
|
||||
recho "$@"
|
||||
|
||||
# this example is straight from the POSIX.2 rationale
|
||||
set foo bar bam
|
||||
|
||||
recho "$@"
|
||||
recho "$*"
|
||||
|
||||
unset IFS
|
||||
|
||||
recho "$@"
|
||||
recho $@
|
||||
recho "$*"
|
||||
|
||||
IFS=:
|
||||
|
||||
# special variables
|
||||
set -- 1 2 3 4 5 6 7 8 9 10
|
||||
|
||||
bar=${*}
|
||||
foo=$*
|
||||
echo foo = "$foo"
|
||||
echo bar = "$bar"
|
||||
|
||||
foo1=$@
|
||||
bar1=${@}
|
||||
|
||||
echo foo1 = "$foo1"
|
||||
echo bar1 = "$bar1"
|
||||
|
||||
foo2="$*"
|
||||
bar2="${*}"
|
||||
|
||||
echo foo2 = "$foo2"
|
||||
echo bar2 = "$bar2"
|
||||
|
||||
eval foo3='$*' bar3='${*}'
|
||||
echo foo3 = "$foo3"
|
||||
echo bar3 = "$bar3"
|
||||
|
||||
case $* in
|
||||
*\:*) echo ok 1;;
|
||||
*) echo bad 1;;
|
||||
esac
|
||||
|
||||
case $@ in
|
||||
*\:*) echo bad 2;;
|
||||
*) echo ok 2;;
|
||||
esac
|
||||
|
||||
case "$*" in
|
||||
*\:*) echo ok 3;;
|
||||
*) echo bad 3;;
|
||||
esac
|
||||
|
||||
case "$@" in
|
||||
*\:*) echo bad 4;;
|
||||
*) echo ok 4;;
|
||||
esac
|
||||
|
||||
IFS=$' \t\n'
|
||||
|
||||
bar=${*}
|
||||
foo=$*
|
||||
echo foo = "$foo"
|
||||
echo bar = "$bar"
|
||||
|
||||
foo1=$@
|
||||
bar1=${@}
|
||||
|
||||
echo foo1 = "$foo1"
|
||||
echo bar1 = "$bar1"
|
||||
|
||||
foo2="$*"
|
||||
bar2="${*}"
|
||||
|
||||
echo foo2 = "$foo2"
|
||||
echo bar2 = "$bar2"
|
||||
|
||||
eval foo3='$*' bar3='${*}'
|
||||
echo foo3 = "$foo3"
|
||||
echo bar3 = "$bar3"
|
||||
|
||||
case $* in
|
||||
*\ *) echo ok 1;;
|
||||
*) echo bad 1;;
|
||||
esac
|
||||
|
||||
case $@ in
|
||||
*\ *) echo ok 2;;
|
||||
*) echo bad 2;;
|
||||
esac
|
||||
|
||||
case "$*" in
|
||||
*\ *) echo ok 3;;
|
||||
*) echo bad 3;;
|
||||
esac
|
||||
|
||||
case "$@" in
|
||||
*\ *) echo ok 4;;
|
||||
*) echo bad 4;;
|
||||
esac
|
||||
|
||||
# tests for special expansion of "$*" and "${array[*]}" when used with other
|
||||
# expansions -- bugs through bash-2.05b
|
||||
${THIS_SH} ./dollar-star1.sub
|
||||
|
||||
# tests for expansion of "$@" on rhs of things like ${param:+word}. Bugs
|
||||
# though bash-2.05b
|
||||
${THIS_SH} ./dollar-at1.sub
|
||||
|
||||
# tests for expansion of other variables in double-quoted strings containing
|
||||
# $@. Bugs through bash-2.05b
|
||||
${THIS_SH} ./dollar-at2.sub
|
||||
|
||||
# tests for various expansions of $* in different contexts -- word split,
|
||||
# no splittin, etc. when $IFS is NUL
|
||||
${THIS_SH} ./dollar-star2.sub
|
||||
|
||||
exit 0
|
||||
@@ -1,127 +0,0 @@
|
||||
argv[1] = <>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <ab>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom dick harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <5>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[1] = <dick>
|
||||
argv[1] = <1>
|
||||
argv[1] = <bob>
|
||||
argv[2] = <tom>
|
||||
argv[3] = <dick>
|
||||
argv[4] = <harry>
|
||||
argv[5] = <joe>
|
||||
argv[1] = <3>
|
||||
argv[1] = <bob>
|
||||
argv[1] = <tom>
|
||||
argv[2] = <dick>
|
||||
argv[3] = <harry>
|
||||
argv[1] = <joe>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foobarbam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo>
|
||||
argv[2] = <bar>
|
||||
argv[3] = <bam>
|
||||
argv[1] = <foo bar bam>
|
||||
foo = 1:2:3:4:5:6:7:8:9:10
|
||||
bar = 1:2:3:4:5:6:7:8:9:10
|
||||
foo1 = 1 2 3 4 5 6 7 8 9 10
|
||||
bar1 = 1 2 3 4 5 6 7 8 9 10
|
||||
foo2 = 1:2:3:4:5:6:7:8:9:10
|
||||
bar2 = 1:2:3:4:5:6:7:8:9:10
|
||||
foo3 = 1:2:3:4:5:6:7:8:9:10
|
||||
bar3 = 1:2:3:4:5:6:7:8:9:10
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
ok 4
|
||||
foo = 1 2 3 4 5 6 7 8 9 10
|
||||
bar = 1 2 3 4 5 6 7 8 9 10
|
||||
foo1 = 1 2 3 4 5 6 7 8 9 10
|
||||
bar1 = 1 2 3 4 5 6 7 8 9 10
|
||||
foo2 = 1 2 3 4 5 6 7 8 9 10
|
||||
bar2 = 1 2 3 4 5 6 7 8 9 10
|
||||
foo3 = 1 2 3 4 5 6 7 8 9 10
|
||||
bar3 = 1 2 3 4 5 6 7 8 9 10
|
||||
ok 1
|
||||
ok 2
|
||||
ok 3
|
||||
ok 4
|
||||
xa|xb|xc
|
||||
xa|xb|xc
|
||||
a|b|c
|
||||
a|b|c
|
||||
a b c
|
||||
a b c
|
||||
xa xb xc
|
||||
xa xb xc
|
||||
a|b
|
||||
b|c
|
||||
a b
|
||||
b c
|
||||
a|b|c
|
||||
a|b|c
|
||||
xa|xb|xc
|
||||
xa|xb|xc
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
3
|
||||
argv[1] = <echo 1 ; echo 1>
|
||||
argv[1] = <echo 1 2 ; echo 1>
|
||||
argv[2] = <2>
|
||||
argv[1] = <echo 1 ; echo 1>
|
||||
argv[1] = <echo 1 2 ; echo 1>
|
||||
argv[2] = <2>
|
||||
@@ -1,100 +0,0 @@
|
||||
./errors.tests: line 17: alias: -x: invalid option
|
||||
alias: usage: alias [-p] [name[=value] ... ]
|
||||
./errors.tests: line 18: unalias: -x: invalid option
|
||||
unalias: usage: unalias [-a] name [name ...]
|
||||
./errors.tests: line 19: alias: hoowah: not found
|
||||
./errors.tests: line 20: unalias: hoowah: not found
|
||||
./errors.tests: line 23: `1': not a valid identifier
|
||||
declare -fr func
|
||||
./errors.tests: line 36: func: readonly function
|
||||
./errors.tests: line 39: unset: -x: invalid option
|
||||
unset: usage: unset [-f] [-v] [name ...]
|
||||
./errors.tests: line 42: unset: func: cannot unset: readonly function
|
||||
./errors.tests: line 45: declare: func: readonly function
|
||||
./errors.tests: line 49: unset: XPATH: cannot unset: readonly variable
|
||||
./errors.tests: line 52: unset: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 55: unset: cannot simultaneously unset a function and a variable
|
||||
./errors.tests: line 58: declare: -z: invalid option
|
||||
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
|
||||
./errors.tests: line 60: declare: `-z': not a valid identifier
|
||||
./errors.tests: line 61: declare: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 65: declare: cannot use `-f' to make functions
|
||||
./errors.tests: line 68: exec: -i: invalid option
|
||||
exec: usage: exec [-cl] [-a name] file [redirection ...]
|
||||
./errors.tests: line 72: export: XPATH: not a function
|
||||
./errors.tests: line 75: break: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 76: continue: only meaningful in a `for', `while', or `until' loop
|
||||
./errors.tests: line 79: shift: label: numeric argument required
|
||||
./errors.tests: line 84: shift: too many arguments
|
||||
./errors.tests: line 90: let: expression expected
|
||||
./errors.tests: line 93: local: can only be used in a function
|
||||
./errors.tests: line 96: logout: not login shell: use `exit'
|
||||
./errors.tests: line 99: hash: notthere: not found
|
||||
./errors.tests: line 102: hash: -v: invalid option
|
||||
hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
||||
./errors.tests: line 106: hash: hashing disabled
|
||||
./errors.tests: line 109: export: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 110: readonly: `AA[4]': not a valid identifier
|
||||
./errors.tests: line 113: [-2]: bad array subscript
|
||||
./errors.tests: line 117: AA: readonly variable
|
||||
./errors.tests: line 121: AA: readonly variable
|
||||
./errors.tests: line 129: shift: 5: shift count out of range
|
||||
./errors.tests: line 130: shift: -2: shift count out of range
|
||||
./errors.tests: line 133: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 134: shopt: no_such_option: invalid shell option name
|
||||
./errors.tests: line 137: umask: 09: octal number out of range
|
||||
./errors.tests: line 138: umask: `:': invalid symbolic mode character
|
||||
./errors.tests: line 139: umask: `:': invalid symbolic mode operator
|
||||
./errors.tests: line 142: umask: -i: invalid option
|
||||
umask: usage: umask [-p] [-S] [mode]
|
||||
./errors.tests: line 146: umask: `u': invalid symbolic mode character
|
||||
./errors.tests: line 155: VAR: readonly variable
|
||||
./errors.tests: line 158: declare: VAR: readonly variable
|
||||
./errors.tests: line 159: declare: VAR: readonly variable
|
||||
./errors.tests: line 161: declare: unset: not found
|
||||
./errors.tests: line 164: VAR: readonly variable
|
||||
./errors.tests: command substitution: line 168: syntax error: unexpected end of file
|
||||
./errors.tests: command substitution: line 168: syntax error near unexpected token `done'
|
||||
./errors.tests: command substitution: line 168: ` for z in 1 2 3; done '
|
||||
./errors.tests: line 171: cd: HOME not set
|
||||
./errors.tests: line 172: cd: /tmp/xyz.bash: No such file or directory
|
||||
./errors.tests: line 174: cd: OLDPWD not set
|
||||
./errors.tests: line 175: cd: /bin/sh: Not a directory
|
||||
./errors.tests: line 177: cd: /tmp/cd-notthere: No such file or directory
|
||||
./errors.tests: line 180: .: filename argument required
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 181: source: filename argument required
|
||||
source: usage: source filename [arguments]
|
||||
./errors.tests: line 184: .: -i: invalid option
|
||||
.: usage: . filename [arguments]
|
||||
./errors.tests: line 187: set: -q: invalid option
|
||||
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
|
||||
./errors.tests: line 190: enable: sh: not a shell builtin
|
||||
./errors.tests: line 190: enable: bash: not a shell builtin
|
||||
./errors.tests: line 193: shopt: cannot set and unset shell options simultaneously
|
||||
./errors.tests: line 196: read: var: invalid timeout specification
|
||||
./errors.tests: line 199: read: `/bin/sh': not a valid identifier
|
||||
./errors.tests: line 202: VAR: readonly variable
|
||||
./errors.tests: line 205: readonly: -x: invalid option
|
||||
readonly: usage: readonly [-af] [name[=value] ...] or readonly -p
|
||||
./errors.tests: line 208: eval: -i: invalid option
|
||||
eval: usage: eval [arg ...]
|
||||
./errors.tests: line 209: command: -i: invalid option
|
||||
command: usage: command [-pVv] command [arg ...]
|
||||
./errors.tests: line 212: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
|
||||
./errors.tests: line 216: trap: NOSIG: invalid signal specification
|
||||
./errors.tests: line 219: trap: -s: invalid option
|
||||
trap: usage: trap [-lp] [arg signal_spec ...]
|
||||
./errors.tests: line 225: return: can only `return' from a function or sourced script
|
||||
./errors.tests: line 229: break: 0: loop count out of range
|
||||
./errors.tests: line 233: continue: 0: loop count out of range
|
||||
./errors.tests: line 238: builtin: bash: not a shell builtin
|
||||
./errors.tests: line 242: bg: no job control
|
||||
./errors.tests: line 243: fg: no job control
|
||||
./errors.tests: line 246: kill: -s: option requires an argument
|
||||
./errors.tests: line 248: kill: S: invalid signal specification
|
||||
./errors.tests: line 250: kill: `': not a pid or valid job spec
|
||||
kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]
|
||||
./errors.tests: line 255: set: trackall: invalid option name
|
||||
./errors.tests: line 262: `!!': not a valid identifier
|
||||
@@ -1,53 +0,0 @@
|
||||
before exec1.sub: one two three
|
||||
calling exec1.sub
|
||||
aa bb cc dd ee
|
||||
after exec1.sub with args: 0
|
||||
|
||||
after exec1.sub without args: 0
|
||||
./execscript: line 20: notthere: command not found
|
||||
127
|
||||
/tmp/bash: notthere: No such file or directory
|
||||
127
|
||||
/bin/sh: /bin/sh: cannot execute binary file
|
||||
126
|
||||
./execscript: line 39: /: is a directory
|
||||
126
|
||||
/: /: cannot execute binary file
|
||||
126
|
||||
./execscript: line 46: .: /: is a directory
|
||||
1
|
||||
127
|
||||
0
|
||||
this is bashenv
|
||||
./exec3.sub: line 3: /tmp/bash-notthere: No such file or directory
|
||||
./exec3.sub: line 3: exec: /tmp/bash-notthere: cannot execute: No such file or directory
|
||||
126
|
||||
./execscript: line 68: notthere: No such file or directory
|
||||
127
|
||||
./execscript: line 71: notthere: No such file or directory
|
||||
127
|
||||
./execscript: line 74: notthere: No such file or directory
|
||||
127
|
||||
this is sh
|
||||
this is sh
|
||||
unset
|
||||
ok
|
||||
5
|
||||
./exec5.sub: line 4: exec: bash-notthere: not found
|
||||
127
|
||||
this is ohio-state
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
||||
42
|
||||
42
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
testb
|
||||
@@ -1,106 +0,0 @@
|
||||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
if [ $UID -eq 0 ]; then
|
||||
echo "execscript: the test suite should not be run as root" >&2
|
||||
fi
|
||||
|
||||
set -- one two three
|
||||
echo before exec1.sub: "$@"
|
||||
echo calling exec1.sub
|
||||
./exec1.sub aa bb cc dd ee
|
||||
echo after exec1.sub with args: $?
|
||||
./exec1.sub
|
||||
echo after exec1.sub without args: $?
|
||||
|
||||
# set up a fixed path so we know notthere will not be found
|
||||
PATH=/usr/bin:/bin:/usr/local/bin:
|
||||
export PATH
|
||||
|
||||
notthere
|
||||
echo $?
|
||||
|
||||
# this is iffy, since the error messages may vary from system to system
|
||||
# and /tmp might not exist
|
||||
ln -s ${THIS_SH} /tmp/bash 2>/dev/null
|
||||
if [ -f /tmp/bash ]; then
|
||||
/tmp/bash notthere
|
||||
else
|
||||
${THIS_SH} notthere
|
||||
fi
|
||||
echo $?
|
||||
rm -f /tmp/bash
|
||||
|
||||
# /bin/sh should be there on all systems
|
||||
${THIS_SH} /bin/sh
|
||||
echo $?
|
||||
|
||||
# try executing a directory
|
||||
/
|
||||
echo $?
|
||||
|
||||
${THIS_SH} /
|
||||
echo $?
|
||||
|
||||
# try sourcing a directory
|
||||
. /
|
||||
echo $?
|
||||
|
||||
# try sourcing a binary file -- post-2.04 versions don't do the binary file
|
||||
# check, and will probably fail with `command not found', or status 127
|
||||
. ${THIS_SH} 2>/dev/null
|
||||
echo $?
|
||||
|
||||
# post-bash-2.05 versions allow sourcing non-regular files
|
||||
. /dev/null
|
||||
echo $?
|
||||
|
||||
# kill two birds with one test -- test out the BASH_ENV code
|
||||
echo echo this is bashenv > /tmp/bashenv
|
||||
export BASH_ENV=/tmp/bashenv
|
||||
${THIS_SH} ./exec3.sub
|
||||
rm -f /tmp/bashenv
|
||||
unset BASH_ENV
|
||||
|
||||
# we're resetting the $PATH to empty, so this should be last
|
||||
PATH=
|
||||
|
||||
notthere
|
||||
echo $?
|
||||
|
||||
command notthere
|
||||
echo $?
|
||||
|
||||
command -p notthere
|
||||
echo $?
|
||||
|
||||
# but -p should guarantee that we find all the standard utilities, even
|
||||
# with an empty or unset $PATH
|
||||
command -p sh -c 'echo this is $0'
|
||||
unset PATH
|
||||
command -p sh -c 'echo this is $0'
|
||||
|
||||
# a bug in bash before bash-2.01 caused PATH to be set to the empty string
|
||||
# when command -p was run with PATH unset
|
||||
echo ${PATH-unset}
|
||||
|
||||
echo "echo ok" | ${THIS_SH} -t
|
||||
|
||||
${THIS_SH} ./exec2.sub
|
||||
echo $?
|
||||
|
||||
${THIS_SH} ./exec4.sub
|
||||
|
||||
# try exec'ing a command that cannot be found in $PATH
|
||||
${THIS_SH} ./exec5.sub
|
||||
|
||||
# this was a bug in bash versions before bash-2.04
|
||||
${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
|
||||
|
||||
# checks for proper return values in subshell commands with inverted return
|
||||
# values
|
||||
|
||||
${THIS_SH} ./exec6.sub
|
||||
|
||||
# checks for properly deciding what constitutes an executable file
|
||||
${THIS_SH} ./exec7.sub
|
||||
@@ -1,374 +0,0 @@
|
||||
#
|
||||
# A suite of tests for bash word expansions
|
||||
#
|
||||
# This tests parameter and variable expansion, with an empahsis on
|
||||
# proper quoting behavior.
|
||||
#
|
||||
# Chet Ramey
|
||||
|
||||
#
|
||||
# If you comment out the body of this function, you can do a diff against
|
||||
# `expansion-tests.right' to see if the shell is behaving correctly
|
||||
#
|
||||
expect()
|
||||
{
|
||||
echo expect "$@"
|
||||
}
|
||||
|
||||
# Test the substitution quoting characters (CTLESC and CTLNUL) in different
|
||||
# combinations
|
||||
|
||||
expect "<^A>"
|
||||
recho `echo ''`
|
||||
expect "<^A>"
|
||||
recho `echo ""`
|
||||
expect "<^B>"
|
||||
recho `echo ''`
|
||||
expect "<^B>"
|
||||
recho `echo ""`
|
||||
expect "<^A>"
|
||||
recho `echo `
|
||||
expect "<^B>"
|
||||
recho `echo `
|
||||
|
||||
# Test null strings without variable expansion
|
||||
expect "<abcdefgh>"
|
||||
recho abcd""efgh
|
||||
expect "<abcdefgh>"
|
||||
recho abcd''efgh
|
||||
expect "<abcdefgh>"
|
||||
recho ""abcdefgh
|
||||
expect "<abcdefgh>"
|
||||
recho ''abcdefgh
|
||||
expect "<abcd>"
|
||||
recho abcd""
|
||||
expect "<abcd>"
|
||||
recho abcd''
|
||||
|
||||
# Test the quirky behavior of $@ in ""
|
||||
expect nothing
|
||||
recho "$@"
|
||||
expect "< >"
|
||||
recho " $@"
|
||||
expect "<-->"
|
||||
recho "-${@}-"
|
||||
|
||||
# Test null strings with variable expansion that fails
|
||||
expect '<>'
|
||||
recho $xxx""
|
||||
expect '<>'
|
||||
recho ""$xxx
|
||||
expect '<>'
|
||||
recho $xxx''
|
||||
expect '<>'
|
||||
recho ''$xxx
|
||||
expect '<>'
|
||||
recho $xxx""$yyy
|
||||
expect '<>'
|
||||
recho $xxx''$yyy
|
||||
|
||||
# Test null strings with variable expansion that succeeds
|
||||
xxx=abc
|
||||
yyy=def
|
||||
|
||||
expect '<abc>'
|
||||
recho $xxx""
|
||||
expect '<abc>'
|
||||
recho ""$xxx
|
||||
expect '<abc>'
|
||||
recho $xxx''
|
||||
expect '<abc>'
|
||||
recho ''$xxx
|
||||
expect '<abcdef>'
|
||||
recho $xxx""$yyy
|
||||
expect '<abcdef>'
|
||||
recho $xxx''$yyy
|
||||
|
||||
unset xxx yyy
|
||||
|
||||
# Test the unquoted special quoting characters
|
||||
expect "<^A>"
|
||||
recho
|
||||
expect "<^B>"
|
||||
recho
|
||||
expect "<^A>"
|
||||
recho ""
|
||||
expect "<^B>"
|
||||
recho ""
|
||||
expect "<^A>"
|
||||
recho ''
|
||||
expect "<^B>"
|
||||
recho ''
|
||||
|
||||
# Test expansion of a variable that is unset
|
||||
expect nothing
|
||||
recho $xxx
|
||||
expect '<>'
|
||||
recho "$xxx"
|
||||
|
||||
expect nothing
|
||||
recho "$xxx${@}"
|
||||
|
||||
# Test empty string expansion
|
||||
expect '<>'
|
||||
recho ""
|
||||
expect '<>'
|
||||
recho ''
|
||||
|
||||
# Test command substitution with (disabled) history substitution
|
||||
expect '<Hello World!>'
|
||||
# set +H
|
||||
recho "`echo \"Hello world!\"`"
|
||||
|
||||
# Test some shell special characters
|
||||
expect '<`>'
|
||||
recho "\`"
|
||||
expect '<">'
|
||||
recho "\""
|
||||
expect '<\^A>'
|
||||
recho "\"
|
||||
|
||||
expect '<\$>'
|
||||
recho "\\$"
|
||||
|
||||
expect '<\\>'
|
||||
recho "\\\\"
|
||||
|
||||
# This should give argv[1] = a argv[2] = b
|
||||
expect '<a> <b>'
|
||||
FOO=`echo 'a b' | tr ' ' '\012'`
|
||||
recho $FOO
|
||||
|
||||
# This should give argv[1] = ^A argv[2] = ^B
|
||||
expect '<^A> <^B>'
|
||||
FOO=`echo ' ' | tr ' ' '\012'`
|
||||
recho $FOO
|
||||
|
||||
# Test quoted and unquoted globbing characters
|
||||
expect '<**>'
|
||||
recho "*"*
|
||||
|
||||
expect '<\.\./*/>'
|
||||
recho "\.\./*/"
|
||||
|
||||
# Test patterns that come up when the shell quotes funny character
|
||||
# combinations
|
||||
expect '<^A^B^A^B>'
|
||||
recho ''
|
||||
expect '<^A^A>'
|
||||
recho ''
|
||||
expect '<^A^B>'
|
||||
recho ''
|
||||
expect '<^A^A^B>'
|
||||
recho ''
|
||||
|
||||
# More tests of "$@"
|
||||
set abc def ghi jkl
|
||||
expect '< abc> <def> <ghi> <jkl >'
|
||||
recho " $@ "
|
||||
expect '< abc> <def> <ghi> <jkl >'
|
||||
recho "${1+ $@ }"
|
||||
|
||||
set abc def ghi jkl
|
||||
expect '<--abc> <def> <ghi> <jkl-->'
|
||||
recho "--$@--"
|
||||
|
||||
set "a b" cd ef gh
|
||||
expect '<a b> <cd> <ef> <gh>'
|
||||
recho ${1+"$@"}
|
||||
expect '<a b> <cd> <ef> <gh>'
|
||||
recho ${foo:-"$@"}
|
||||
expect '<a b> <cd> <ef> <gh>'
|
||||
recho "${@}"
|
||||
|
||||
expect '< >'
|
||||
recho " "
|
||||
expect '< - >'
|
||||
recho " - "
|
||||
|
||||
# Test combinations of different types of quoting in a fully-quoted string
|
||||
# (so the WHOLLY_QUOTED tests fail and it doesn't get set)
|
||||
expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
|
||||
recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
|
||||
|
||||
# Test the various Posix parameter expansions
|
||||
|
||||
expect '<foo bar>'
|
||||
recho "${x:-$(echo "foo bar")}"
|
||||
expect '<foo> <bar>'
|
||||
recho ${x:-$(echo "foo bar")}
|
||||
|
||||
unset X
|
||||
expect '<abc>'
|
||||
recho ${X:=abc}
|
||||
expect '<abc>'
|
||||
recho $X
|
||||
|
||||
set a b c
|
||||
expect '<posix>'
|
||||
recho ${3:+posix}
|
||||
|
||||
POSIX=/usr/posix
|
||||
expect '<10>'
|
||||
recho ${#POSIX}
|
||||
|
||||
# remove shortest trailing match
|
||||
x=file.c
|
||||
expect '<file.o>'
|
||||
recho ${x%.c}.o
|
||||
|
||||
# remove longest trailing match
|
||||
x=posix/src/std
|
||||
expect '<posix>'
|
||||
recho ${x%%/*}
|
||||
|
||||
# remove shortest leading pattern
|
||||
x=$HOME/src/cmd
|
||||
expect '</src/cmd>'
|
||||
recho ${x#$HOME}
|
||||
|
||||
# remove longest leading pattern
|
||||
x=/one/two/three
|
||||
expect '<three>'
|
||||
recho ${x##*/}
|
||||
|
||||
# pattern removal of patterns that don't match
|
||||
z=abcdef
|
||||
|
||||
expect '<abcdef>'
|
||||
recho ${z#xyz}
|
||||
expect '<abcdef>'
|
||||
recho ${z##xyz}
|
||||
|
||||
expect '<abcdef>'
|
||||
recho ${z%xyz}
|
||||
expect '<abcdef>'
|
||||
recho ${z%%xyz}
|
||||
|
||||
# Command substitution and the quirky differences between `` and $()
|
||||
|
||||
expect '<\$x>'
|
||||
recho '\$x'
|
||||
|
||||
expect '<$x>'
|
||||
recho `echo '\$x'`
|
||||
|
||||
expect '<\$x>'
|
||||
recho $(echo '\$x')
|
||||
|
||||
# The difference between $* "$*" and "$@"
|
||||
|
||||
set "abc" "def ghi" "jkl"
|
||||
|
||||
expect '<abc> <def> <ghi> <jkl>'
|
||||
recho $*
|
||||
|
||||
expect '<abc def ghi jkl>'
|
||||
recho "$*"
|
||||
|
||||
OIFS="$IFS"
|
||||
IFS=":$IFS"
|
||||
|
||||
# The special behavior of "$*", using the first character of $IFS as separator
|
||||
expect '<abc:def ghi:jkl>'
|
||||
recho "$*"
|
||||
|
||||
IFS="$OIFS"
|
||||
|
||||
expect '<abc> <def ghi> <jkl>'
|
||||
recho "$@"
|
||||
|
||||
expect '<xxabc> <def ghi> <jklyy>'
|
||||
recho "xx$@yy"
|
||||
|
||||
expect '<abc> <def ghi> <jklabc> <def ghi> <jkl>'
|
||||
recho "$@$@"
|
||||
|
||||
foo=abc
|
||||
bar=def
|
||||
|
||||
expect '<abcdef>'
|
||||
recho "$foo""$bar"
|
||||
|
||||
unset foo
|
||||
set $foo bar '' xyz "$foo" abc
|
||||
|
||||
expect '<bar> <> <xyz> <> <abc>'
|
||||
recho "$@"
|
||||
|
||||
# More tests of quoting and deferred evaluation
|
||||
|
||||
foo=10 x=foo
|
||||
y='$'$x
|
||||
expect '<$foo>'
|
||||
recho $y
|
||||
eval y='$'$x
|
||||
expect '<10>'
|
||||
recho $y
|
||||
|
||||
# case statements
|
||||
|
||||
NL='
|
||||
'
|
||||
x='ab
|
||||
cd'
|
||||
|
||||
expect '<newline expected>'
|
||||
case "$x" in
|
||||
*$NL*) recho "newline expected" ;;
|
||||
esac
|
||||
|
||||
expect '<got it>'
|
||||
case \? in
|
||||
*"?"*) recho "got it" ;;
|
||||
esac
|
||||
|
||||
expect '<got it>'
|
||||
case \? in
|
||||
*\?*) recho "got it" ;;
|
||||
esac
|
||||
|
||||
set one two three four five
|
||||
expect '<one> <three> <five>'
|
||||
recho $1 $3 ${5} $8 ${9}
|
||||
|
||||
# length tests on positional parameters and some special parameters
|
||||
|
||||
expect '<5> <5>'
|
||||
recho $# ${#}
|
||||
expect '<3>'
|
||||
recho ${#1}
|
||||
expect '<1>'
|
||||
recho ${##}
|
||||
expect '<1>'
|
||||
recho ${#?}
|
||||
expect '<5>'
|
||||
recho ${#@}
|
||||
expect '<5>'
|
||||
recho ${#*}
|
||||
expect '<5>'
|
||||
recho "${#@}"
|
||||
expect '<5>'
|
||||
recho "${#*}"
|
||||
|
||||
expect '<42>'
|
||||
recho $((28 + 14))
|
||||
expect '<26>'
|
||||
recho $[ 13 * 2 ]
|
||||
|
||||
expect '<\>'
|
||||
recho `echo \\\\`
|
||||
|
||||
expect '<~>'
|
||||
recho '~'
|
||||
|
||||
expect nothing
|
||||
recho $!
|
||||
expect nothing
|
||||
recho ${!}
|
||||
|
||||
# test word splitting of assignment statements not preceding a command
|
||||
a="a b c d e"
|
||||
declare b=$a
|
||||
expect '<a> <b> <c> <d> <e>'
|
||||
recho $b
|
||||
@@ -1,26 +0,0 @@
|
||||
match 1
|
||||
match 2
|
||||
match 3
|
||||
match 4
|
||||
match 1a
|
||||
match 1b
|
||||
match 2a
|
||||
match 2b
|
||||
match 3a
|
||||
match 3b
|
||||
match 4a
|
||||
match 4b
|
||||
match 5
|
||||
match 6
|
||||
match 7
|
||||
match 8
|
||||
match 9
|
||||
match 10
|
||||
match 11
|
||||
match 12
|
||||
match 13
|
||||
match 14
|
||||
match 15
|
||||
match 16
|
||||
match 17
|
||||
match 18
|
||||
@@ -1,53 +0,0 @@
|
||||
shopt -s extglob
|
||||
|
||||
[[ ab/../ == @(ab|+([^/]))/..?(/) ]] && echo match 1
|
||||
|
||||
[[ ab/../ == +([^/])/..?(/) ]] && echo match 2
|
||||
|
||||
[[ ab/../ == @(ab|?b)/..?(/) ]] && echo match 3
|
||||
|
||||
[[ ab/../ == +([^/])/../ ]] && echo match 4
|
||||
|
||||
[[ ab/../ == +([!/])/..?(/) ]] && echo match 1a
|
||||
|
||||
[[ ab/../ == @(ab|+([!/]))/..?(/) ]] && echo match 1b
|
||||
|
||||
[[ ab/../ == +([!/])/../ ]] && echo match 2a
|
||||
|
||||
[[ ab/../ == +([!/])/..?(/) ]] && echo match 2b
|
||||
|
||||
[[ ab/../ == +([!/])/..@(/) ]] && echo match 3a
|
||||
|
||||
[[ ab/../ == +(ab)/..?(/) ]] && echo match 3b
|
||||
|
||||
[[ ab/../ == [!/][!/]/../ ]] && echo match 4a
|
||||
|
||||
[[ ab/../ == @(ab|?b)/..?(/) ]] && echo match 4b
|
||||
|
||||
[[ ab/../ == [^/][^/]/../ ]] && echo match 5
|
||||
|
||||
[[ ab/../ == ?b/..?(/) ]] && echo match 6
|
||||
|
||||
[[ ab/../ == +(?b)/..?(/) ]] && echo match 7
|
||||
|
||||
[[ ab/../ == +(?b|?b)/..?(/) ]] && echo match 8
|
||||
|
||||
[[ ab/../ == @(?b|?b)/..?(/) ]] && echo match 9
|
||||
|
||||
[[ ab/../ == @(a?|?b)/..?(/) ]] && echo match 10
|
||||
|
||||
[[ ab/../ == ?(ab)/..?(/) ]] && echo match 11
|
||||
|
||||
[[ ab/../ == ?(ab|??)/..?(/) ]] && echo match 12
|
||||
|
||||
[[ ab/../ == @(??)/..?(/) ]] && echo match 13
|
||||
|
||||
[[ ab/../ == @(??|a*)/..?(/) ]] && echo match 14
|
||||
|
||||
[[ ab/../ == @(a*)/..?(/) ]] && echo match 15
|
||||
|
||||
[[ ab/../ == +(??)/..?(/) ]] && echo match 16
|
||||
|
||||
[[ ab/../ == +(??|a*)/..?(/) ]] && echo match 17
|
||||
|
||||
[[ ab/../ == +(a*)/..?(/) ]] && echo match 18
|
||||
@@ -1,28 +0,0 @@
|
||||
abcde
|
||||
yo
|
||||
hot damn
|
||||
what a fabulous window treatment
|
||||
double"quote
|
||||
onetwothree
|
||||
first second third
|
||||
f1 ()
|
||||
{
|
||||
cat <<< "abcde";
|
||||
cat <<< "yo";
|
||||
cat <<< "$a $b";
|
||||
cat <<< 'what a fabulous window treatment';
|
||||
cat <<< 'double"quote'
|
||||
}
|
||||
f2 ()
|
||||
{
|
||||
cat <<< onetwothree
|
||||
}
|
||||
f3 ()
|
||||
{
|
||||
cat <<< "$@"
|
||||
}
|
||||
echo $(echo hi)
|
||||
echo ho
|
||||
echo off to work we go
|
||||
declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i\
|
||||
")'
|
||||
@@ -1,97 +0,0 @@
|
||||
trap 'rm /tmp/newhistory' 0
|
||||
|
||||
# bad options
|
||||
history -x
|
||||
# cannot use -r and -w at the same time
|
||||
history -r -w /dev/null
|
||||
|
||||
# bad option
|
||||
fc -v
|
||||
|
||||
# all of these should result in an empty history list
|
||||
history -c
|
||||
history -r /dev/null
|
||||
history -n /dev/null
|
||||
history -c
|
||||
|
||||
HISTFILE=history.list
|
||||
HISTCONTROL=ignoreboth
|
||||
HISTIGNORE='&:history*:fc*'
|
||||
HISTSIZE=32
|
||||
|
||||
shopt -s cmdhist
|
||||
set -o history
|
||||
|
||||
history
|
||||
|
||||
fc -l
|
||||
fc -nl
|
||||
|
||||
fc -lr
|
||||
fc -nlr
|
||||
|
||||
history -s "echo line for history"
|
||||
history
|
||||
|
||||
history -p '!!'
|
||||
|
||||
fc -nl
|
||||
|
||||
HISTFILE=/tmp/newhistory
|
||||
history -a
|
||||
echo displaying \$HISTFILE after history -a
|
||||
cat $HISTFILE
|
||||
|
||||
history
|
||||
history -w
|
||||
cat $HISTFILE
|
||||
|
||||
history -s "echo line 2 for history"
|
||||
history
|
||||
history -p '!e'
|
||||
history -p '!!'
|
||||
|
||||
# this should show up as one history entry
|
||||
for x in one two three
|
||||
do
|
||||
:
|
||||
done
|
||||
history
|
||||
|
||||
# just a basic test. a full test suite for history expansion should be
|
||||
# created
|
||||
set -H
|
||||
!!
|
||||
!e
|
||||
|
||||
unset HISTSIZE
|
||||
unset HISTFILE
|
||||
|
||||
fc -l 4
|
||||
fc -l 4 8
|
||||
|
||||
fc -l 502
|
||||
fc -l one=two three=four 502
|
||||
|
||||
history 4
|
||||
|
||||
shopt -so history
|
||||
shopt -s expand_aliases
|
||||
|
||||
alias r="fc -s"
|
||||
|
||||
echo aa ab ac
|
||||
|
||||
r a=x
|
||||
r x=4 b=8
|
||||
|
||||
# this had better fail with `no command found'
|
||||
r cc
|
||||
|
||||
unalias -a
|
||||
alias
|
||||
|
||||
set +o history
|
||||
|
||||
shopt -q -o history
|
||||
echo $?
|
||||
@@ -1,38 +0,0 @@
|
||||
LANG=en_US.UTF-8
|
||||
|
||||
a=$'\303\251'
|
||||
|
||||
echo "$a"
|
||||
|
||||
echo ${#a}
|
||||
|
||||
b=$'A\303\251B'
|
||||
|
||||
echo "$b"
|
||||
|
||||
echo ${b: -1}
|
||||
|
||||
c=AeB
|
||||
|
||||
echo ${c: -1}
|
||||
|
||||
unset a
|
||||
a=$(printf '%b' 'A\303\251B')
|
||||
IFS=$(printf '%b' '\303\251')
|
||||
|
||||
case "$a" in
|
||||
"A${IFS}B") echo ok 1 ;;
|
||||
*) echo bad 1 ;;
|
||||
esac
|
||||
|
||||
set $a
|
||||
|
||||
case $1 in
|
||||
A) echo ok 2 ;;
|
||||
*) echo bad 2 ;;
|
||||
esac
|
||||
|
||||
set a b
|
||||
|
||||
printf '%s\n' "$*"
|
||||
printf '%s' "$*" | od -b
|
||||
@@ -1,33 +0,0 @@
|
||||
argv[1] = <xxxyyy>
|
||||
argv[1] = <xxx^?yyy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <x^?y>
|
||||
argv[1] = <-->
|
||||
argv[1] = <-^?->
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^?yy>
|
||||
0x7f
|
||||
0x7f
|
||||
0x7f
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^?@>
|
||||
argv[1] = <@^?@>
|
||||
argv[1] = <@^?>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^?@>
|
||||
argv[1] = <@^?@>
|
||||
argv[1] = <@^?>
|
||||
argv[1] = <1>
|
||||
argv[2] = <^?>
|
||||
argv[3] = <^?>
|
||||
argv[1] = <2>
|
||||
argv[2] = <^?a>
|
||||
argv[3] = <^?a>
|
||||
argv[1] = <2>
|
||||
argv[2] = <^?a>
|
||||
argv[3] = <^?a>
|
||||
argv[1] = <3>
|
||||
argv[2] = <^?aa>
|
||||
argv[3] = <^?aa>
|
||||
@@ -1,86 +0,0 @@
|
||||
# bug in bash up to and including bash-3.0 (including patches)
|
||||
#
|
||||
# problem is conflict between CTLNUL used internally to denote quoted null
|
||||
# characters and its value (0x7f) appearing in the expansion of a variable
|
||||
#
|
||||
unset x
|
||||
recho "xxx${x}yyy"
|
||||
|
||||
y=$'\177'
|
||||
recho "xxx${y}yyy"
|
||||
|
||||
unset y
|
||||
|
||||
unset undef
|
||||
|
||||
set ""
|
||||
recho ${undef-"x$*y"}
|
||||
|
||||
set $'\177'
|
||||
recho ${undef-"x$*y"}
|
||||
|
||||
shift $#
|
||||
|
||||
f()
|
||||
{
|
||||
recho "-${*-x}-"
|
||||
}
|
||||
|
||||
f ''
|
||||
f $'\177'
|
||||
|
||||
unset -f f
|
||||
|
||||
x=12345
|
||||
|
||||
recho "${x:6:1}"
|
||||
|
||||
x=
|
||||
recho "${x:0:1}"
|
||||
|
||||
y=$'\177'
|
||||
recho "${y:0:1}"
|
||||
|
||||
y=xxx$'\177'yyy
|
||||
recho "${y:3:3}"
|
||||
|
||||
unset x y
|
||||
|
||||
eval tmp=`printf "$'\\\\\x%x'\n" 127`
|
||||
printf "%#1x\n" "'$tmp"
|
||||
|
||||
x=$'\177'
|
||||
printf "%#1x\n" "'$x"
|
||||
|
||||
a=127
|
||||
eval c=\$\'\\$(printf '%o' $a)\'
|
||||
printf "%#1x\n" "'$c"
|
||||
|
||||
recho "$c"
|
||||
recho "$c"@
|
||||
recho @"$c"@
|
||||
recho @"$c"
|
||||
|
||||
recho "$c"
|
||||
recho "$c@"
|
||||
recho "@$c@"
|
||||
recho "@$c"
|
||||
|
||||
unset tmp x a c
|
||||
|
||||
qtest()
|
||||
{
|
||||
recho ${#q} "${q}" ${q}
|
||||
}
|
||||
|
||||
q=$'\x7f'
|
||||
qtest
|
||||
|
||||
q=${q}a
|
||||
qtest
|
||||
|
||||
q=$'\x7fa'
|
||||
qtest
|
||||
|
||||
q="${q}a"
|
||||
qtest
|
||||
@@ -1,105 +0,0 @@
|
||||
./jobs2.sub: line 9: fg: job 1 started without job control
|
||||
fg: 1
|
||||
Waiting for job 0
|
||||
job 0 returns 0
|
||||
Waiting for job 1
|
||||
job 1 returns 0
|
||||
Waiting for job 2
|
||||
job 2 returns 0
|
||||
Waiting for job 3
|
||||
job 3 returns 0
|
||||
Waiting for job 4
|
||||
job 4 returns 0
|
||||
Waiting for job 5
|
||||
job 5 returns 0
|
||||
Waiting for job 6
|
||||
job 6 returns 0
|
||||
Waiting for job 7
|
||||
job 7 returns 0
|
||||
[1] Running sleep 5 &
|
||||
[2] Running sleep 5 &
|
||||
[3] Running sleep 5 &
|
||||
[4]- Running sleep 5 &
|
||||
[5]+ Running ( sleep 5; exit 4 ) &
|
||||
4
|
||||
0
|
||||
i killed it
|
||||
0
|
||||
./jobs.tests: line 19: wait: %1: no such job
|
||||
./jobs.tests: line 24: fg: no job control
|
||||
wait-for-pid
|
||||
wait-errors
|
||||
./jobs.tests: line 37: wait: `1-1': not a pid or valid job spec
|
||||
./jobs.tests: line 38: wait: `-4': not a pid or valid job spec
|
||||
wait-for-background-pids
|
||||
async list wait-for-background-pids
|
||||
async list wait for child
|
||||
forked
|
||||
wait-when-no-children
|
||||
wait-for-job
|
||||
./jobs.tests: line 60: wait: %2: no such job
|
||||
127
|
||||
async list wait-for-job
|
||||
forked
|
||||
fg-bg 1
|
||||
sleep 5
|
||||
fg-bg 2
|
||||
sleep 5
|
||||
fg-bg 3
|
||||
sleep 5
|
||||
fg-bg 4
|
||||
sleep 5
|
||||
fg-bg 5
|
||||
./jobs.tests: line 87: fg: %2: no such job
|
||||
./jobs.tests: line 88: bg: job 1 already in background
|
||||
fg-bg 6
|
||||
./jobs.tests: line 95: fg: -s: invalid option
|
||||
fg: usage: fg [job_spec]
|
||||
./jobs.tests: line 96: bg: -s: invalid option
|
||||
bg: usage: bg [job_spec]
|
||||
./jobs.tests: line 101: disown: -s: invalid option
|
||||
disown: usage: disown [-h] [-ar] [jobspec ...]
|
||||
./jobs.tests: line 105: disown: %1: no such job
|
||||
./jobs.tests: line 108: disown: %2: no such job
|
||||
wait-for-non-child
|
||||
./jobs.tests: line 111: wait: pid 1 is not a child of this shell
|
||||
127
|
||||
3 -- 1 2 3 -- 1 - 2 - 3
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
running jobs:
|
||||
[1] Running sleep 300 &
|
||||
[2]- Running sleep 350 &
|
||||
[3]+ Running sleep 400 &
|
||||
./jobs.tests: line 127: kill: %4: no such job
|
||||
./jobs.tests: line 129: jobs: %4: no such job
|
||||
current job:
|
||||
[3]+ Running sleep 400 &
|
||||
previous job:
|
||||
[2]- Running sleep 350 &
|
||||
after kill -STOP
|
||||
running jobs:
|
||||
[1] Running sleep 300 &
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
[2]+ Stopped sleep 350
|
||||
after disown
|
||||
[2]+ Stopped sleep 350
|
||||
[3]- Running sleep 400 &
|
||||
running jobs:
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
[2]+ Stopped sleep 350
|
||||
after kill -s CONT
|
||||
running jobs:
|
||||
[2]+ Running sleep 350 &
|
||||
[3]- Running sleep 400 &
|
||||
stopped jobs:
|
||||
after kill -STOP, backgrounding %3:
|
||||
[3]+ sleep 400 &
|
||||
killing...
|
||||
done
|
||||
after KILL -STOP, foregrounding %1
|
||||
sleep 10
|
||||
done
|
||||
@@ -1,50 +0,0 @@
|
||||
:; ./shx
|
||||
|
||||
sh:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:00 EDT 1992
|
||||
bang geoff
|
||||
quote 712824302
|
||||
setbq defmsgid=<1992Aug3.024502.6176@host>
|
||||
bgwait sleep done... wait 6187
|
||||
|
||||
|
||||
bash:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:09 EDT 1992
|
||||
bang geoff
|
||||
quote 712824311
|
||||
setbq defmsgid=<1992Aug3.024512.6212@host>
|
||||
bgwait sleep done... wait 6223
|
||||
|
||||
|
||||
ash:
|
||||
<&$fd shx1: 4: Syntax error: Bad fd number
|
||||
nlbq Mon Aug 3 02:45:19 EDT 1992
|
||||
bang geoff
|
||||
quote getdate: `"now"' not a valid date
|
||||
|
||||
setbq defmsgid=<1992Aug3.` echo 024521
|
||||
bgwait sleep done... wait 6241
|
||||
|
||||
|
||||
ksh:
|
||||
<&$fd ok
|
||||
nlbq ./shx: 6248 Memory fault - core dumped
|
||||
bang geoff
|
||||
quote getdate: `"now"' not a valid date
|
||||
|
||||
setbq defmsgid=<1992Aug3.024530.6257@host>
|
||||
bgwait no such job: 6265
|
||||
wait 6265
|
||||
sleep done...
|
||||
|
||||
zsh:
|
||||
<&$fd ok
|
||||
nlbq Mon Aug 3 02:45:36 EDT 1992
|
||||
bang shx3: event not found: /s/ [4]
|
||||
quote 712824337
|
||||
setbq defmsgid=<..6290@host>
|
||||
bgwait shx7: unmatched " [9]
|
||||
sleep done...
|
||||
:;
|
||||
@@ -1,10 +0,0 @@
|
||||
#! /bin/sh
|
||||
for cmd in sh bash ash ksh zsh
|
||||
do
|
||||
echo
|
||||
echo $cmd:
|
||||
for demo in shx?
|
||||
do
|
||||
$cmd $demo
|
||||
done
|
||||
done
|
||||
@@ -1,214 +0,0 @@
|
||||
argv[1] = <aaa bbb ccc>
|
||||
argv[1] = <aaa bbb ccc>
|
||||
argv[1] = <baz:bar>
|
||||
argv[1] = <baz:bar>
|
||||
argv[1] = <aaa bbb ccc>
|
||||
argv[1] = <bar>
|
||||
argv[1] = <bar>
|
||||
argv[1] = <bar>
|
||||
argv[1] = <abcde>
|
||||
argv[1] = <abcde>
|
||||
argv[1] = <xyz>
|
||||
argv[1] = <a b>
|
||||
argv[2] = <c>
|
||||
argv[3] = <d>
|
||||
argv[4] = <e>
|
||||
argv[5] = <f>
|
||||
argv[1] = <a b>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[1] = <a b>
|
||||
argv[2] = <c>
|
||||
argv[3] = <d>
|
||||
argv[4] = <e>
|
||||
argv[5] = <f>
|
||||
argv[1] = <a b>
|
||||
argv[2] = <c>
|
||||
argv[3] = <d>
|
||||
argv[4] = <e>
|
||||
argv[5] = <f>
|
||||
argv[1] = </usr/homes/chet>
|
||||
argv[1] = <~>
|
||||
argv[1] = <~>
|
||||
argv[1] = <\~>
|
||||
argv[1] = <\ \~>
|
||||
argv[1] = <\ \ \~>
|
||||
argv[1] = </usr/homes/chet>
|
||||
argv[1] = </usr/homes/chet>
|
||||
argv[1] = </usr/homes/chet>
|
||||
argv[1] = <$HOME>
|
||||
argv[1] = <\ $HOME>
|
||||
argv[1] = <\ \ $HOME>
|
||||
argv[1] = <'bar'>
|
||||
argv[1] = <'bar'>
|
||||
argv[1] = <*@>
|
||||
argv[1] = <*@>
|
||||
argv[1] = <*@>
|
||||
argv[1] = <*@>
|
||||
argv[1] = <*@*>
|
||||
argv[1] = <*@*>
|
||||
argv[1] = <*@*>
|
||||
argv[1] = <*@*>
|
||||
argv[1] = <abcd>
|
||||
argv[1] = <efghijkl>
|
||||
argv[1] = <4>
|
||||
argv[2] = <2>
|
||||
argv[1] = <1>
|
||||
argv[1] = <bar>
|
||||
argv[1] = <2>
|
||||
argv[1] = <bar>
|
||||
argv[1] = <2>
|
||||
argv[1] = <4>
|
||||
argv[1] = <--\>
|
||||
argv[2] = <-->
|
||||
argv[1] = <--\^J-->
|
||||
argv[1] = <--+\>
|
||||
argv[2] = <+-->
|
||||
argv[1] = <--+\^J+-->
|
||||
argv[1] = <-+\>
|
||||
argv[2] = <+-\>
|
||||
argv[3] = <->
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <xy>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <x>
|
||||
argv[1] = <x>
|
||||
argv[1] = <>
|
||||
argv[1] = <x>
|
||||
argv[1] = <x>
|
||||
argv[1] = <x>
|
||||
argv[1] = <x>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <^?>
|
||||
argv[1] = <x>
|
||||
argv[1] = <x>
|
||||
argv[1] = <>
|
||||
argv[2] = <abd>
|
||||
argv[3] = <x>
|
||||
argv[1] = <>
|
||||
argv[2] = <abd>
|
||||
argv[3] = <>
|
||||
argv[1] = <a,b,c,d,e,f>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[6] = <f>
|
||||
./more-exp.tests: line 272: abc=def: command not found
|
||||
argv[1] = <a b c d e>
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
argv[4] = <d>
|
||||
argv[5] = <e>
|
||||
argv[1] = <foo)>
|
||||
argv[1] = <a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\\a>
|
||||
argv[1] = <a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\\a>
|
||||
argv[1] = <a>
|
||||
argv[1] = <a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <$a>
|
||||
argv[1] = <\foo>
|
||||
argv[1] = <$a>
|
||||
argv[1] = <\foo>
|
||||
argv[1] = <\$a>
|
||||
argv[1] = <\\$a>
|
||||
argv[1] = <a>
|
||||
argv[1] = <a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <\a>
|
||||
argv[1] = <G>
|
||||
argv[2] = <{>
|
||||
argv[3] = <I>
|
||||
argv[4] = <K>
|
||||
argv[5] = <}>
|
||||
argv[1] = <hi>
|
||||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
argv[1] = <a*>
|
||||
Number of args: 0
|
||||
<${*-x}>: <x>
|
||||
<${@-x}>: <x>
|
||||
Number of args: 1
|
||||
<${*-x}>: <>
|
||||
<${@-x}>: <>
|
||||
Number of args: 2
|
||||
<${*-x}>: < >
|
||||
<${@-x}>: < >
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <posparams>
|
||||
argv[1] = <posparams>
|
||||
argv[1] = <2>
|
||||
argv[1] = <0>
|
||||
argv[1] = <0>
|
||||
argv[1] = <1>
|
||||
argv[1] = <5>
|
||||
argv[1] = <5>
|
||||
argv[1] = <0>
|
||||
./more-exp.tests: line 420: ${#:}: bad substitution
|
||||
./more-exp.tests: line 422: ${#/}: bad substitution
|
||||
./more-exp.tests: line 424: ${#%}: bad substitution
|
||||
./more-exp.tests: line 426: ${#=}: bad substitution
|
||||
./more-exp.tests: line 428: ${#+}: bad substitution
|
||||
./more-exp.tests: line 430: ${#1xyz}: bad substitution
|
||||
./more-exp.tests: line 433: #: %: syntax error: operand expected (error token is "%")
|
||||
argv[1] = <0>
|
||||
argv[1] = <a+b>
|
||||
argv[1] = <+>
|
||||
argv[1] = <+>
|
||||
argv[1] = <+>
|
||||
argv[1] = <G { I >
|
||||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
argv[1] = <hi>
|
||||
argv[2] = <K>
|
||||
argv[3] = <}>
|
||||
argv[1] = <xxx>
|
||||
argv[2] = <yyy>
|
||||
1
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
argv[1] = <:a:>
|
||||
argv[1] = <:b:>
|
||||
argv[1] = <>
|
||||
argv[1] = <>
|
||||
@@ -1,501 +0,0 @@
|
||||
expect()
|
||||
{
|
||||
echo expect "$@"
|
||||
}
|
||||
|
||||
tool_var() {
|
||||
eval $1=\"\${$1:-$2}\"
|
||||
export $1
|
||||
}
|
||||
|
||||
A="aaa bbb ccc"
|
||||
|
||||
unset B
|
||||
|
||||
tool_var B ${B:-"$A"}
|
||||
|
||||
expect '<aaa bbb ccc>'
|
||||
recho "$A"
|
||||
expect '<aaa bbb ccc>'
|
||||
recho "$B"
|
||||
|
||||
eto_prepend() {
|
||||
eval $1=\'$2\''${'$1':+":"${'$1'}}'; export $1
|
||||
}
|
||||
|
||||
foo=bar; export foo
|
||||
eto_prepend foo baz
|
||||
expect '<baz:bar>'
|
||||
recho $foo
|
||||
expect '<baz:bar>'
|
||||
recho ${foo-"bar"}
|
||||
|
||||
aa='aaa bbb ccc'
|
||||
|
||||
expect '<aaa bbb ccc>'
|
||||
recho ${zzz-"$aa"}
|
||||
expect '<bar>'
|
||||
recho ${zzz:-"bar"}
|
||||
expect '<bar>'
|
||||
recho "${zzz:-bar}"
|
||||
expect '<bar>'
|
||||
recho "${zzz:-"bar"}"
|
||||
|
||||
var=abcde
|
||||
expect '<abcde>'
|
||||
recho "${var:-xyz}"
|
||||
expect '<abcde>'
|
||||
recho "${var:=xyz}"
|
||||
expect '<xyz>'
|
||||
recho "${var:+xyz}"
|
||||
|
||||
set 'a b' c d e f
|
||||
expect '<a b> <c> <d> <e> <f>'
|
||||
recho ${1+"$@"}
|
||||
expect '<a b>'
|
||||
recho "${1-"$@"}"
|
||||
expect '<a> <b>'
|
||||
recho ${1-"$@"}
|
||||
expect '<a b> <c> <d> <e> <f>'
|
||||
recho "${1+$@}"
|
||||
expect '<a b> <c> <d> <e> <f>'
|
||||
recho "${1+"$@"}"
|
||||
|
||||
HOME=/usr/homes/chet
|
||||
somevar=
|
||||
expect "<$HOME>"
|
||||
recho ${somevar:-~}
|
||||
expect "<$HOME>"
|
||||
recho "${somevar:-~}"
|
||||
expect '<~>'
|
||||
recho "${somevar:-"~"}"
|
||||
expect '<\~>'
|
||||
recho "${somevar:-\~}"
|
||||
expect '<\ \~>'
|
||||
recho "${somevar:-\ \~}"
|
||||
expect '<\ \ \~>'
|
||||
recho "${somevar:-\ \ \~}"
|
||||
|
||||
expect "<$HOME>"
|
||||
recho ${somevar:-$HOME}
|
||||
expect "<$HOME>"
|
||||
recho "${somevar:-$HOME}"
|
||||
expect "<$HOME>"
|
||||
recho "${somevar:-"$HOME"}"
|
||||
expect '<$HOME>'
|
||||
recho "${somevar:-\$HOME}"
|
||||
expect '<\ $HOME>'
|
||||
recho "${somevar:-\ \$HOME}"
|
||||
expect '<\ \ $HOME>'
|
||||
recho "${somevar:-\ \ \$HOME}"
|
||||
|
||||
foo=bar
|
||||
expect "<'bar'>"
|
||||
recho "${foo+'$foo'}"
|
||||
expect "<'bar'>"
|
||||
recho "${fox='$foo'}"
|
||||
|
||||
P='*@*'
|
||||
expect '<*@>'
|
||||
recho "${P%"*"}"
|
||||
expect '<*@>'
|
||||
recho "${P%'*'}"
|
||||
|
||||
expect '<*@>'
|
||||
recho ${P%"*"}
|
||||
expect '<*@>'
|
||||
recho ${P%'*'}
|
||||
|
||||
expect '<*@*>'
|
||||
recho ${P%""}
|
||||
expect '<*@*>'
|
||||
recho ${P#""}
|
||||
|
||||
expect '<*@*>'
|
||||
recho ${P#"$foobar"}
|
||||
expect '<*@*>'
|
||||
recho ${P%"$foobar"}
|
||||
|
||||
s1=abcdefghijkl
|
||||
s2=efgh
|
||||
|
||||
first=${s1/$s2*/}
|
||||
expect '<abcd>'
|
||||
recho $first
|
||||
|
||||
last=${s1##$first}
|
||||
expect '<efghijkl>'
|
||||
recho $last
|
||||
|
||||
shift $#
|
||||
UNAME_RELEASE=${1:-4.2MP}
|
||||
|
||||
RELEASE=`expr "$UNAME_RELEASE" : '[^0-9]*\([0-9]*\)'` # 4
|
||||
case "$RELEASE" in
|
||||
"") RELEASE=0 ;;
|
||||
*) RELEASE=`expr "$RELEASE" + 0` ;;
|
||||
esac
|
||||
REL_LEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.\([0-9]*\)'` # 1
|
||||
REL_SUBLEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.[0-9]*.\([0-9]*\)'` # 2
|
||||
|
||||
expect '<4> <2>'
|
||||
recho $RELEASE $REL_LEVEL $REL_SUBLEVEL
|
||||
|
||||
b1()
|
||||
{
|
||||
b2 ${1+"$@"}
|
||||
}
|
||||
|
||||
b2()
|
||||
{
|
||||
recho $*
|
||||
recho $#
|
||||
}
|
||||
|
||||
expect '<1>'
|
||||
b1 ''
|
||||
|
||||
expect '<bar> <2>'
|
||||
b1 bar ''
|
||||
|
||||
expect '<bar> <2>'
|
||||
b1 '' bar
|
||||
|
||||
expect '<4>'
|
||||
b1 '' '' '' ''
|
||||
|
||||
NL="\\
|
||||
"
|
||||
|
||||
NNL="+$NL+"
|
||||
|
||||
expect '<--\> <-->'
|
||||
recho --$NL--
|
||||
expect '<--\^J-->'
|
||||
recho "--$NL--"
|
||||
|
||||
expect '<--+\> <+-->'
|
||||
recho --$NNL--
|
||||
expect '<--+\^J+-->'
|
||||
recho "--$NNL--"
|
||||
|
||||
expect '<-+\> <+-\> <->'
|
||||
recho -$NNL-$NL-
|
||||
|
||||
set ''
|
||||
expect '<xy>'
|
||||
recho "$*xy"
|
||||
expect '<xy>'
|
||||
recho "x$*y"
|
||||
expect '<xy>'
|
||||
recho "xy$*"
|
||||
expect '<xy>'
|
||||
recho x"$*"y
|
||||
expect '<xy>'
|
||||
recho xy"$*"
|
||||
expect '<xy>'
|
||||
recho "$*"xy
|
||||
expect '<>'
|
||||
recho "$*"
|
||||
expect nothing
|
||||
recho $*
|
||||
|
||||
unset undef ; set ""
|
||||
|
||||
expect '<>'
|
||||
recho ${undef-"$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"x$*y"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"$*xy"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"xy$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-x"$*"y}
|
||||
expect '<xy>'
|
||||
recho ${undef-xy"$*"}
|
||||
expect '<xy>'
|
||||
recho ${undef-"$*"xy}
|
||||
expect '<>'
|
||||
recho "${undef-$*}"
|
||||
expect nothing
|
||||
recho ${undef-$*}
|
||||
|
||||
expect '<>'
|
||||
recho ${undef-"$zzz"}
|
||||
expect '<x>'
|
||||
recho x${undef-"$zzz"}
|
||||
expect '<x>'
|
||||
recho x${undef-"$@"}
|
||||
expect nothing
|
||||
recho ${undef-"$@"}
|
||||
expect '<x>'
|
||||
recho ${undef-"$zzz"}x
|
||||
expect '<x>'
|
||||
recho ${undef-"$@"}x
|
||||
expect '<x>'
|
||||
recho "$@"x
|
||||
expect '<x>'
|
||||
recho "$zzz"x
|
||||
expect '<^?>'
|
||||
recho ${undef-}
|
||||
expect '<^?>'
|
||||
recho ${undef-""}
|
||||
|
||||
yyy=""
|
||||
recho "$xxx"x
|
||||
recho "$yyy"x
|
||||
|
||||
set "" "abd" ""
|
||||
recho "$@"x
|
||||
recho "$@"$xxx
|
||||
|
||||
OIFS="$IFS"
|
||||
|
||||
arg=a,b,c,d,e,f
|
||||
|
||||
IFS=,
|
||||
|
||||
export z=$arg
|
||||
|
||||
eval z1=\"$arg\"
|
||||
|
||||
IFS="$OIFS"
|
||||
|
||||
recho $z
|
||||
recho $z1
|
||||
|
||||
# should give an error
|
||||
abc\=def
|
||||
|
||||
zz="a b c d e"
|
||||
declare a=$zz
|
||||
|
||||
recho "$a"
|
||||
recho $a
|
||||
|
||||
recho $(echo "foo$(echo ")")")
|
||||
|
||||
# test backslash escapes
|
||||
|
||||
recho \a
|
||||
recho \\a
|
||||
|
||||
recho "\a"
|
||||
recho "\\a"
|
||||
|
||||
recho '\a'
|
||||
recho '\\a'
|
||||
|
||||
recho $(zecho \a)
|
||||
recho $(zecho \\a)
|
||||
|
||||
recho $(zecho "\a")
|
||||
recho $(zecho "\\a")
|
||||
|
||||
recho $(zecho '\a')
|
||||
recho $(zecho '\\a')
|
||||
|
||||
recho `zecho \a`
|
||||
recho `zecho \\a`
|
||||
|
||||
recho `zecho "\a"`
|
||||
recho `zecho "\\a"`
|
||||
|
||||
recho `zecho '\a'`
|
||||
recho `zecho '\\a'`
|
||||
|
||||
a=foo
|
||||
|
||||
recho \$a
|
||||
recho \\$a
|
||||
|
||||
recho "\$a"
|
||||
recho "\\$a"
|
||||
|
||||
recho '\$a'
|
||||
recho '\\$a'
|
||||
|
||||
recho $(zecho `zecho \a`)
|
||||
recho $(zecho `zecho \\a`)
|
||||
|
||||
recho $(zecho `zecho "\a"`)
|
||||
recho $(zecho `zecho "\\a"`)
|
||||
|
||||
recho $(zecho `zecho '\a'`)
|
||||
recho $(zecho `zecho '\\a'`)
|
||||
|
||||
# should echo G { I K }
|
||||
recho ${abc:-G { I } K }
|
||||
|
||||
abc=hi
|
||||
|
||||
# should echo hi K }
|
||||
recho ${abc:-G { I } K }
|
||||
|
||||
# should echo a*
|
||||
unset foo
|
||||
recho "${foo:-"a"}*"
|
||||
|
||||
f ()
|
||||
{
|
||||
echo "Number of args: $#"
|
||||
echo "<\${*-x}>: <${*-x}>"
|
||||
echo "<\${@-x}>: <${@-x}>"
|
||||
}
|
||||
|
||||
f
|
||||
f ''
|
||||
f '' ''
|
||||
|
||||
set 1 2 3 4 5
|
||||
|
||||
expect '<5>'
|
||||
recho ${#}
|
||||
expect '<5>'
|
||||
recho ${#:foo}
|
||||
expect '<5>'
|
||||
recho ${#:-foo}
|
||||
expect '<5>'
|
||||
recho ${#-posparams}
|
||||
expect '<5>'
|
||||
recho ${#:-posparams}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#!}
|
||||
|
||||
expect nothing
|
||||
recho $!
|
||||
expect nothing
|
||||
recho ${!}
|
||||
|
||||
expect nothing
|
||||
recho $8
|
||||
expect nothing
|
||||
recho ${8}
|
||||
|
||||
shift $#
|
||||
|
||||
expect '<0>'
|
||||
recho ${#}
|
||||
expect '<0>'
|
||||
recho ${#:foo}
|
||||
expect '<0>'
|
||||
recho ${#:-foo}
|
||||
expect '<0>'
|
||||
recho ${#-posparams}
|
||||
expect '<0>'
|
||||
recho ${#:-posparams}
|
||||
|
||||
expect '<posparams>'
|
||||
recho ${!-posparams}
|
||||
expect '<posparams>'
|
||||
recho ${!:-posparams}
|
||||
|
||||
expect '<2>'
|
||||
recho ${#-}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#-posparams}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#?:-xyz}
|
||||
|
||||
expect '<1>'
|
||||
recho ${#?}
|
||||
|
||||
set a b c d e
|
||||
|
||||
expect '<5>'
|
||||
recho ${#}
|
||||
expect '<5>'
|
||||
recho ${#?:-xyz}
|
||||
|
||||
shift $#
|
||||
|
||||
expect '<0>'
|
||||
recho ${#:-foo}
|
||||
|
||||
expect a bad substitution error
|
||||
recho ${#:}
|
||||
expect a bad substitution error
|
||||
recho ${#/}
|
||||
expect a bad substitution error
|
||||
recho ${#%}
|
||||
expect a bad substitution error
|
||||
recho ${#=}
|
||||
expect a bad substitution error
|
||||
recho ${#+}
|
||||
expect a bad substitution error
|
||||
recho ${#1xyz}
|
||||
|
||||
expect a math syntax error
|
||||
recho ${#:%}
|
||||
|
||||
expect '<0>'
|
||||
recho ${#:-}
|
||||
|
||||
set --
|
||||
unset a b
|
||||
|
||||
x=a
|
||||
y=b
|
||||
|
||||
IFS=+
|
||||
|
||||
expect '<a+b>'
|
||||
recho $x+$y
|
||||
expect '<+>'
|
||||
recho $a+$b
|
||||
|
||||
expect '<+>'
|
||||
recho + "$@"
|
||||
expect '<+>'
|
||||
recho +"$@"
|
||||
|
||||
# variants of nested curly braces inside ${...} expressions
|
||||
|
||||
# IFS is not the standard one
|
||||
|
||||
expect '<G { I>' '<K>' '<}>'
|
||||
recho ${gik:-G { I } K }
|
||||
|
||||
abc=hi
|
||||
|
||||
expect '<hi>' '<K>' '<}>'
|
||||
recho ${abc:-G { I } K }
|
||||
|
||||
# reset IFS to the default
|
||||
IFS='
|
||||
'
|
||||
|
||||
# nested ${...} inside ${...} are handled specially
|
||||
unset XXX FOO BAR
|
||||
expect '<xxx>' '<yyy>'
|
||||
XXX=xxx
|
||||
FOO=${BAR:-${XXX} yyy}
|
||||
recho $FOO
|
||||
|
||||
# this was a bug in versions of bash prior to bash-2.04-release
|
||||
set -- ''
|
||||
expect 1
|
||||
echo $#
|
||||
expect '<>'
|
||||
recho "${@}"
|
||||
expect '<>'
|
||||
recho "${@-}"
|
||||
expect '<>'
|
||||
recho "${@:-}"
|
||||
|
||||
# this was a bug in bash-2.04, fixed in 2.05
|
||||
set -- a b
|
||||
expect '<:a:>' '<:b:>'
|
||||
for i in "${@-}"; do recho :$i:; done
|
||||
|
||||
# I believe that ksh93 does these wrong -- we're using the rhs, so shouldn't
|
||||
# it behave the same as ""?
|
||||
set --
|
||||
expect '<>'
|
||||
recho "${@-}"
|
||||
expect '<>'
|
||||
recho "${@:-}"
|
||||
@@ -1,98 +0,0 @@
|
||||
abc
|
||||
./redir.tests: line 13: /tmp/redir-test: cannot overwrite existing file
|
||||
abc
|
||||
def
|
||||
def
|
||||
./redir.tests: line 29: $z: ambiguous redirect
|
||||
Point 1
|
||||
Point 2
|
||||
to a
|
||||
to b
|
||||
Point 3
|
||||
to a
|
||||
to a
|
||||
to b
|
||||
to b
|
||||
Point 4
|
||||
to c
|
||||
Point 5
|
||||
this is redir1.sub
|
||||
this is redir2.sub
|
||||
read line1 "ab"
|
||||
read line2 "root"
|
||||
read line3 "cd"
|
||||
read line4 "daemon"
|
||||
from stdin: aa
|
||||
to stdout
|
||||
./redir4.sub: line 32: $fd: ambiguous redirect
|
||||
./redir4.sub: line 33: $fd: ambiguous redirect
|
||||
/tmp/err-and-out:
|
||||
to stdout
|
||||
to stderr
|
||||
/tmp/err-and-out:
|
||||
to stdout
|
||||
to stderr
|
||||
0 -- 3 0
|
||||
0 -- 4 0
|
||||
ab
|
||||
cd
|
||||
ef
|
||||
gh
|
||||
ij
|
||||
kl
|
||||
0
|
||||
ab
|
||||
cd
|
||||
cd
|
||||
./redir.tests: line 152: redir1.*: No such file or directory
|
||||
# tests of ksh93-like dup-and-close redirection operators
|
||||
exec 9<$0
|
||||
|
||||
f()
|
||||
{
|
||||
exec 5<$0
|
||||
|
||||
exec 0<&5-
|
||||
|
||||
while read line; do
|
||||
echo "$line"
|
||||
done
|
||||
}
|
||||
|
||||
f
|
||||
|
||||
typeset -f f
|
||||
|
||||
# make sure it was closed
|
||||
read -u 5 foo
|
||||
echo after read
|
||||
|
||||
exec 5<&0
|
||||
|
||||
exec <&-
|
||||
|
||||
read abcde
|
||||
|
||||
exec 0<&9-
|
||||
read line
|
||||
echo $line
|
||||
f ()
|
||||
{
|
||||
exec 5<$0;
|
||||
exec 0<&5-;
|
||||
while read line; do
|
||||
echo "$line";
|
||||
done
|
||||
}
|
||||
./redir5.sub: line 20: read: 5: invalid file descriptor: Bad file descriptor
|
||||
after read
|
||||
./redir5.sub: line 27: read: read error: 0: Bad file descriptor
|
||||
# tests of ksh93-like dup-and-close redirection operators
|
||||
/
|
||||
/
|
||||
/
|
||||
0
|
||||
0
|
||||
0
|
||||
before block
|
||||
after block
|
||||
@@ -1,173 +0,0 @@
|
||||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# catch-all for remaining untested redirection stuff
|
||||
set +o posix
|
||||
|
||||
echo abc > /tmp/redir-test
|
||||
cat /tmp/redir-test
|
||||
|
||||
set -o noclobber
|
||||
|
||||
#this should be an error
|
||||
echo def > /tmp/redir-test
|
||||
cat /tmp/redir-test
|
||||
|
||||
# but this should succeed
|
||||
echo def > /tmp/redir-test-2
|
||||
cat /tmp/redir-test-2
|
||||
|
||||
# and so should this
|
||||
echo def >| /tmp/redir-test
|
||||
cat /tmp/redir-test
|
||||
|
||||
set +o noclobber
|
||||
rm /tmp/redir-test /tmp/redir-test-2
|
||||
|
||||
# this should be an error
|
||||
z="a b"
|
||||
cat < $z
|
||||
|
||||
echo "Point 1"
|
||||
|
||||
exec 3</etc/passwd
|
||||
exec 4>/tmp/bash-a
|
||||
exec 5>/tmp/bash-b
|
||||
echo "Point 2"
|
||||
|
||||
echo to a 1>&4
|
||||
echo to b 1>&5
|
||||
cat /tmp/bash-a
|
||||
cat /tmp/bash-b
|
||||
exec 11</dev/null
|
||||
echo "Point 3"
|
||||
|
||||
echo to a 1>&4
|
||||
echo to b 1>&5
|
||||
cat /tmp/bash-a
|
||||
cat /tmp/bash-b
|
||||
|
||||
exec 11<&-
|
||||
echo "Point 4"
|
||||
|
||||
exec 6<>/tmp/bash-c
|
||||
echo to c 1>&6
|
||||
cat /tmp/bash-c
|
||||
echo "Point 5"
|
||||
|
||||
rm -f /tmp/bash-a /tmp/bash-b /tmp/bash-c
|
||||
|
||||
#
|
||||
# Test the effect of input buffering on the shell's input
|
||||
#
|
||||
${THIS_SH} < redir1.sub
|
||||
|
||||
# more open, close, duplicate file descriptors
|
||||
${THIS_SH} ./redir3.sub < ./redir3.in1
|
||||
|
||||
# still more redirections
|
||||
${THIS_SH} ./redir4.sub < redir4.in1
|
||||
|
||||
# various forms of null redirection
|
||||
testf()
|
||||
{
|
||||
if [ -f "$1" ]; then
|
||||
rm -f "$1"
|
||||
else
|
||||
echo oops -- $1 not found
|
||||
fi
|
||||
}
|
||||
|
||||
> /tmp/null-redir-a
|
||||
testf /tmp/null-redir-a
|
||||
|
||||
$EXIT > /tmp/null-redir-b
|
||||
testf /tmp/null-redir-b
|
||||
|
||||
( > /tmp/null-redir-c )
|
||||
testf /tmp/null-redir-c
|
||||
|
||||
$EXIT > /tmp/null-redir-d &
|
||||
wait
|
||||
testf /tmp/null-redir-d
|
||||
|
||||
exit 3 | $EXIT > /tmp/null-redir-e
|
||||
echo $? -- ${PIPESTATUS[@]}
|
||||
testf /tmp/null-redir-e
|
||||
|
||||
exit 4 | > /tmp/null-redir-f
|
||||
echo $? -- ${PIPESTATUS[@]}
|
||||
testf /tmp/null-redir-f
|
||||
|
||||
> /tmp/null-redir-g &
|
||||
wait
|
||||
testf /tmp/null-redir-g
|
||||
|
||||
exec >/tmp/null-redir-h &
|
||||
wait
|
||||
testf /tmp/null-redir-h
|
||||
|
||||
# make sure async commands don't get /dev/null as stdin when an explicit
|
||||
# input redirection is supplied
|
||||
for x in 1 2 3; do
|
||||
{ read line ; echo $line ; } &
|
||||
wait
|
||||
{ read line ; echo $line ; } &
|
||||
wait
|
||||
done << EOF
|
||||
ab
|
||||
cd
|
||||
ef
|
||||
gh
|
||||
ij
|
||||
kl
|
||||
EOF
|
||||
|
||||
# make sure async commands get /dev/null as stdin in the absence of any
|
||||
# input redirection
|
||||
/bin/cat &
|
||||
wait
|
||||
echo $?
|
||||
|
||||
# make sure that loops work OK with here documents and are not run in
|
||||
# subshells
|
||||
while read line; do
|
||||
echo $line
|
||||
l2=$line
|
||||
done << EOF
|
||||
ab
|
||||
cd
|
||||
EOF
|
||||
echo $l2
|
||||
|
||||
# These should not echo anything -- bug in versions before 2.04
|
||||
( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1
|
||||
|
||||
( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 | cat
|
||||
|
||||
# in posix mode, non-interactive shells are not allowed to perform
|
||||
# filename expansion on input redirections, even if they expand to
|
||||
# a single filename
|
||||
set -o posix
|
||||
cat < redir1.*
|
||||
|
||||
# test ksh93 dup-and-close (move fd) redirections
|
||||
${THIS_SH} ./redir5.sub
|
||||
|
||||
# test behavior after a write error with a builtin command
|
||||
${THIS_SH} ./redir6.sub
|
||||
|
||||
# problem with redirections using fds bash uses internally
|
||||
: ${TMPDIR:=/tmp}
|
||||
|
||||
trap 'rm -f $TMPDIR/bash-redir-$$' 0 1 2 3 6 15
|
||||
|
||||
echo before block
|
||||
{
|
||||
echo before redir
|
||||
exec 10>&1
|
||||
echo after redir
|
||||
} > $TMPDIR/bash-redir-$$
|
||||
|
||||
echo after block
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
echo "warning: all of these tests will fail if arrays have not" >&2
|
||||
echo "warning: been compiled into the shell" >&2
|
||||
${THIS_SH} ./array.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx array.right && rm -f /tmp/xx
|
||||
@@ -1,7 +0,0 @@
|
||||
# See whether or not we can use `diff -a'
|
||||
( diff -a ./intl.right ./intl.right >/dev/null 2>&1 ) && AFLAG=-a
|
||||
|
||||
echo "warning: some of these tests will fail if you do not have UTF-8" >&2
|
||||
echo "warning: locales installed on your system." >&2
|
||||
${THIS_SH} ./intl.tests > /tmp/xx
|
||||
diff $AFLAG /tmp/xx intl.right && rm -f /tmp/xx
|
||||
@@ -1,4 +0,0 @@
|
||||
echo "warning: different versions of wc put differing amounts of whitespace" >&2
|
||||
echo "warning: before their output. Please do not consider this an error." >&2
|
||||
${THIS_SH} ./read.tests > /tmp/xx 2>&1
|
||||
diff /tmp/xx read.right && rm -f /tmp/xx
|
||||
@@ -1,62 +0,0 @@
|
||||
HOME=/usr/xyz
|
||||
XPATH=/bin:/usr/bin:.
|
||||
|
||||
ADDPATH=PATH=~/bin:$XPATH
|
||||
|
||||
echo $ADDPATH
|
||||
|
||||
unset ADDPATH
|
||||
: ${ADDPATH:=~/bin:~/bin2:$XPATH}
|
||||
echo $ADDPATH
|
||||
|
||||
unset ADDPATH
|
||||
: ${ADDPATH:=PATH=~/bin:~/bin2:$XPATH}
|
||||
echo $ADDPATH
|
||||
|
||||
cat << !
|
||||
~/bin
|
||||
!
|
||||
|
||||
echo "~"
|
||||
|
||||
echo ${TPATH:-~}
|
||||
echo "${TPATH:-~}"
|
||||
echo "${TPATH:-"~"}"
|
||||
|
||||
echo "${XPATH+~}"
|
||||
|
||||
recho "\a"
|
||||
recho "${TPATH:-\a}"
|
||||
|
||||
SHELL=~/bash
|
||||
echo $SHELL
|
||||
|
||||
case $SHELL in
|
||||
~/bash) echo ok;;
|
||||
*) echo bad;;
|
||||
esac
|
||||
|
||||
somevar=
|
||||
echo "${somevar:-~}"
|
||||
echo "${somevar:-"~"}"
|
||||
|
||||
echo make -k FOO=~/mumble
|
||||
|
||||
typeset FOO=~/mumble
|
||||
echo "$FOO"
|
||||
|
||||
h=HOME=~
|
||||
echo $h
|
||||
|
||||
export h=HOME=~
|
||||
echo $h
|
||||
|
||||
x=1234
|
||||
HOME='/usr/$x/abc'
|
||||
|
||||
echo ~
|
||||
|
||||
eval echo $h
|
||||
eval $h
|
||||
|
||||
echo $HOME
|
||||
@@ -1,48 +0,0 @@
|
||||
./type.tests: line 9: type: -r: invalid option
|
||||
type: usage: type [-afptP] name [name ...]
|
||||
./type.tests: line 12: type: notthere: not found
|
||||
function
|
||||
keyword
|
||||
builtin
|
||||
file
|
||||
file
|
||||
file
|
||||
func is a function
|
||||
func ()
|
||||
{
|
||||
echo this is func
|
||||
}
|
||||
while is a shell keyword
|
||||
while is a shell keyword
|
||||
builtin is a shell builtin
|
||||
/bin/sh is /bin/sh
|
||||
func
|
||||
func is a function
|
||||
func ()
|
||||
{
|
||||
echo this is func
|
||||
}
|
||||
while
|
||||
while is a shell keyword
|
||||
./type.tests: line 42: type: m: not found
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
m is aliased to `more'
|
||||
alias
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
alias m='more'
|
||||
m is aliased to `more'
|
||||
builtin
|
||||
builtin is a shell builtin
|
||||
/bin/sh
|
||||
/bin/sh is /bin/sh
|
||||
./type.tests: line 64: type: func: not found
|
||||
./type.tests: line 66: type: m: not found
|
||||
/bin/sh
|
||||
/tmp/bash
|
||||
bash is hashed (/tmp/bash)
|
||||
file
|
||||
hits command
|
||||
3 /tmp/bash
|
||||
1 /bin/sh
|
||||
@@ -1,81 +0,0 @@
|
||||
set +o posix
|
||||
|
||||
hash -r
|
||||
unalias -a
|
||||
|
||||
# this should echo nothing
|
||||
type
|
||||
# this should be a usage error
|
||||
type -r ${THIS_SH}
|
||||
|
||||
# these should behave identically
|
||||
type notthere
|
||||
command -v notthere
|
||||
|
||||
alias m=more
|
||||
|
||||
unset -f func 2>/dev/null
|
||||
func() { echo this is func; }
|
||||
|
||||
type -t func
|
||||
type -t while
|
||||
type -t builtin
|
||||
type -t /bin/sh
|
||||
type -t ${THIS_SH}
|
||||
type -t mv
|
||||
|
||||
type func
|
||||
# the following two should produce identical output
|
||||
type while
|
||||
type -a while
|
||||
type builtin
|
||||
type /bin/sh
|
||||
|
||||
command -v func
|
||||
command -V func
|
||||
command -v while
|
||||
command -V while
|
||||
|
||||
# the following three lines should produce the same output
|
||||
# first test with alias expansion off (should all fail or produce no output)
|
||||
type -t m
|
||||
type m
|
||||
command -v m
|
||||
alias -p
|
||||
alias m
|
||||
|
||||
# then test with alias expansion on
|
||||
shopt -s expand_aliases
|
||||
type m
|
||||
type -t m
|
||||
command -v m
|
||||
alias -p
|
||||
alias m
|
||||
|
||||
command -V m
|
||||
shopt -u expand_aliases
|
||||
|
||||
command -v builtin
|
||||
command -V builtin
|
||||
command -v /bin/sh
|
||||
command -V /bin/sh
|
||||
|
||||
unset -f func
|
||||
type func
|
||||
unalias m
|
||||
type m
|
||||
|
||||
hash -r
|
||||
|
||||
hash -p /bin/sh sh
|
||||
type -p sh
|
||||
|
||||
SHBASE=${THIS_SH##*/}
|
||||
hash -p /tmp/$SHBASE $SHBASE
|
||||
type -p $SHBASE
|
||||
type $SHBASE
|
||||
|
||||
type -t $SHBASE
|
||||
|
||||
# make sure the hash table looks right
|
||||
hash
|
||||
Reference in New Issue
Block a user