Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7796267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:19:19+00:00 2026-06-01T23:19:19+00:00

I’m working with a bash script that has the following syntax $ declare -a

  • 0

I’m working with a bash script that has the following syntax

$ declare -a THIS[*]

This seems to be illegal in zsh (I get a “no matches found: THIS[*]” error). Can anyone help me translate this to zsh?

Also – what does the [*] syntax mean? (I know we’re declaring an array, but why the [*]?)

update

To provide an example of where the code is used, and explain how it is valid – I’ve copied a few lines from Eric Engstrom’s post on password 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 the [*] is being used as some kind of dynamic iterator (as we don’t know how many items it will have later). I’d just like to know of the equivalent declaration in zsh!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:19:21+00:00Added an answer on June 1, 2026 at 11:19 pm

    Only Bash has declare. The kshes and zsh have typeset. That code is nonsensical in all of them, and since shells disagree about the parsing of the arguments to declaration commands like declare and typeset (with Bash in particular, -a alters parsing in a specific way), it’s going to do a different unpredictable, potentially dangerous thing in each.

    Specifically how Bash is interpreting this – from the manpage:

    declare -a name[subscript] is also accepted; the subscript is ignored.

    So since it’s unquoted – if there’s a file in the current directory named THIS* then Bash would throw an illegal name error due to the pathname expansion. Otherwise it will just create an empty array named “THIS”.

    What [*] means depends upon context. Unquoted in an ordinary command evaluation context, it’s a character class matching only literal asterisks. If used in a parameter expansion following an array name, it expands all elements of the array to a single word separated by the first character of IFS.

    declare in bash declares variables, returns their values, sets attributes, and affects function scope. See: http://wiki.bash-hackers.org/commands/builtin/declare

    edit: Given the example that’s now in the question, in bash the behavior is as described above. The [*] should be deleted from the declare. That code has a number of other issues such as attempting to put arguments into strings, using all-caps variable names, and using [ instead of [[ in a script that’s clearly not intended to run on a minimal POSIX sh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.