1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
# These tests deal with parameters
#
name: parameters-1
description:
Check setting of positional parameters
category: debian,posix
stdin:
set -- To comply or not to comply. That is the question.
echo 1: $1
echo 2: $2
echo 3: $3
echo 4: $4
echo 5: $5
echo 6: $6
echo 7: $7
echo 8: $8
echo 9: $9
echo 10: $10
echo 10 again, with feeling: ${10}
expected-stdout:
1: To
2: comply
3: or
4: not
5: to
6: comply.
7: That
8: is
9: the
10: To0
10 again, with feeling: question.
---
name: parameters-2
description:
Check expansion of special parameters
category: debian,posix
stdin:
set -- To comply or not to comply. That was the question.
echo $@
echo "$@"
echo $*
echo "$*"
echo This should be 10: $#.
echo Now once more with IFS changed.
IFS=":"
echo $@
echo "$@"
echo $*
echo "$*"
echo That was exciting.
echo "Exit status: $?"
expected-stdout:
To comply or not to comply. That was the question.
To comply or not to comply. That was the question.
To comply or not to comply. That was the question.
To comply or not to comply. That was the question.
This should be 10: 10.
Now once more with IFS changed.
To comply or not to comply. That was the question.
To comply or not to comply. That was the question.
To comply or not to comply. That was the question.
To:comply:or:not:to:comply.:That:was:the:question.
That was exciting.
Exit status: 0
---
name: parameters-3
description:
Check PWD parameter
category: debian,posix
stdin:
cd /
pwd
/bin/pwd
echo $PWD
expected-stdout:
/
/
/
---
name: parameters-4
description:
Check parameter expansions
category: debian,posix
stdin:
FULLPARAMETER="yes"
NULLPARAMETER=""
echo ${FULLPARAMETER:-one}
echo ${EMPTYPARAMETER:-two}
echo ${NULLPARAMETER:-three}
echo ${FULLPARAMETER-four}
echo ${EMPTYPARAMETER-five}
echo ${NULLPARAMETER-six}
echo ${FULLPARAMETER:=seven}
echo ${EMPTYPARAMETER:=eight}
echo ${FULLPARAMETER:+nine}
echo ${EMPTYPARAMETER:+ten}
echo ${NEWEMPTYPARAMETER:+eleven}
echo ${NULLPARAMETER:+twelve}
echo ${FULLPARAMETER+thirteen}
echo ${EMPTYPARAMETER+fourteen}
echo ${NEWEMPTYPARAMETER+fifteen}
echo ${NULLPARAMETER?seventeen}
echo ${FULLPARAMETER:?eighteen}
echo ${EMPTYPARAMETER:?nineteen}
expected-stdout:
yes
two
three
yes
five
yes
eight
nine
ten
thirteen
fourteen
yes
eight
---
name: parameters-5
description:
Check parameter expansion substrings
category: debian,posix
stdin:
TESTSTRING="abcDEF"
echo ${TESTSTRING%[A-Z]?}
echo ${TESTSTRING%%[A-Z]?}
echo ${TESTSTRING#[a-z]?}
echo ${TESTSTRING##[a-z]?}
expected-stdout:
abcD
abcD
cDEF
cDEF
---
|