In case you got here with an Android script shell, you might need to know that Android uses MKSH, and not full Bash, which has some effects. Check this:
#!/system/bin/sh echo "KSH_VERSION: $KSH_VERSION" local -i aa=1 typeset -i bb=1 declare -i cc=1 aa=aa+1; bb=bb+1; cc=cc+1; echo "No fun:" echo " local aa=$aa" echo " typset bb=$bb" echo " declare cc=$cc" myfun() { local -i aaf=1 typeset -i bbf=1 declare -i ccf=1 aaf=aaf+1; bbf=bbf+1; ccf=ccf+1; echo "With fun:" echo " local aaf=$aaf" echo " typset bbf=$bbf" echo " declare ccf=$ccf" } myfun;
Running this, we get:
# woot.sh KSH_VERSION: @(#)MIRBSD KSH R50 2015/04/19 /system/xbin/woot.sh[6]: declare: not found No fun: local aa=2 typset bb=2 declare cc=cc+1 /system/xbin/woot.sh[31]: declare: not found With fun: local aaf=2 typset bbf=2 declare ccf=ccf+1
So in Android declare does not exist. But while reading, others should be equivalent.
not2qubit
source share