I am working with a bash script that has the following syntax
$ declare -a THIS[*]
This seems illegal in zsh (I get a "match not found: THIS [*]" error). Can someone help me translate this to zsh?
Also - what does the syntax mean [*]? (I know that we are declaring an array, but why [*]?)
Update
To give an example of the use of the code and explain how it is valid, I copied a few lines from the Eric Engstrom message to the password for free SSH
declare -a SSSHA_KEYS[*]
sssha_parse_args() {
local OPTIND=1
while getopts "xe:k:t:" OPT; do
case $OPT in
t) SSSHA_ARGS="-t $OPTARG" ;;
e) SSSHA_ENV="$OPTARG" ;;
k) [ -f "${OPTARG}" ] && SSSHA_KEYS[${#SSSHA_KEYS[*]}]="$OPTARG" ;;
x) SSSHA_STOP_ON_EXIT=$OPT
esac
done
shift $(($OPTIND - 1))
if [ -z "${SSSHA_KEYS[*]}" ]; then
for key in $HOME/.ssh/id_[rd]sa; do
[ -f "$key" ] && SSSHA_KEYS[${#SSSHA_KEYS[*]}]="$key"
done
fi
}
I believe that it is [*]used as a kind of dynamic iterator (since we don’t know how many elements it will have later). I would just like to know the equivalent declaration in zsh!
source
share