summaryrefslogtreecommitdiffhomepage
path: root/tests/zash/typeset.sh
blob: a02dd92d414225748f5be320ca5de97af4be5fc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# typeset / integer.
typeset -i n=2+3; echo $n
n=n*4; echo $n
n=abc; echo $n
typeset +i n; n=1+1; echo $n
integer k=10; k=k/3; echo $k
typeset -x EXP=yes; $TSH -c 'echo "exported=$EXP"'
typeset +x EXP; $TSH -c 'echo "exported=${EXP-no}"'
typeset -r RO=fixed; (RO=changed) 2>/dev/null; echo "RO=$RO status=$?"
typeset -ix both=6*7; $TSH -c 'echo $both'
g=global
f() { typeset g=local; typeset -i m=1+1; echo "$g $m"; }
f; echo "$g [${m-unset}]"
typeset plain=p; echo $plain
typeset -i | grep -c '^integer both='
typeset -x | grep -c '^export both='
typeset -q 2>/dev/null; echo "status=$?"
typeset 1bad=x 2>/dev/null; echo "status=$?"
for i in 1 2 3; do integer sum; sum=sum+i; done; echo $sum