Bash, zsh: declare [*] (oh mine)

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[*]

# --- PARSE ARGS --- #
sssha_parse_args() {
  local OPTIND=1
  while getopts "xe:k:t:" OPT; do
    #echo "$OPT $OPTARG $OPTIND"
    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))

  # set default key, if none specified
  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!

+3
source share
1

Bash declare. Kshes zsh typeset. , , declare typeset ( , Bash, -a ), , .

, Bash - manpage:

declare -a [ ] ; .

, - THIS*, Bash - . "THIS".

[*], . , , . , , IFS.

declare Bash , , . .: http://wiki.bash-hackers.org/commands/builtin/declare

edit. , , Bash , . [*] declare. , , all-caps [ [[ script, POSIX sh.

+3

All Articles