Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link
  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674https://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

    For example, ${myarr+1} and [[ -v myarr ]] are the applications to an array myarr the usual ways of testing if a variable/parameter is set. Which does myarr in them mean: myarr[0], or the entire array myarr?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

    For example, ${myarr+1} and [[ -v myarr ]] are the applications to an array myarr the usual ways of testing if a variable/parameter is set. Which does myarr in them mean: myarr[0], or the entire array myarr?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from https://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

    For example, ${myarr+1} and [[ -v myarr ]] are the applications to an array myarr the usual ways of testing if a variable/parameter is set. Which does myarr in them mean: myarr[0], or the entire array myarr?

  3. What is POSIX definition for a shell array being set?

added 16 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

    For example, when applying${myarr+1} and [[ -v myarr ]] are the applications to an array myarr the usual ways of testing if a variable/parameter is set, which. Which does myarr in ${myarr+1} and [[ -v myarr ]] them mean: myarr[0], or the entire array myarr?

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    For example, when applying to an array myarr the usual ways of testing if a variable/parameter is set, which does myarr in ${myarr+1} and [[ -v myarr ]] mean: myarr[0], or the entire array myarr?

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

    For example, ${myarr+1} and [[ -v myarr ]] are the applications to an array myarr the usual ways of testing if a variable/parameter is set. Which does myarr in them mean: myarr[0], or the entire array myarr?

  3. What is POSIX definition for a shell array being set?

deleted 6 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There areis a different definitionsdefinition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Are these definitionsIs this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    For example, when applying to an array myarr the usual ways of testing if a variable/parameter is set, which does myarr in ${myarr+1} and [[ -v myarr ]] mean: myarr[0], or the entire array myarr?

    So are these definitionsis this definition actually for the element indexed by index/key 0 being set, not for the array being set?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There are different definitions for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Are these definitions incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    For example, when applying to an array myarr the usual ways of testing if a variable/parameter is set, which does myarr in ${myarr+1} and [[ -v myarr ]] mean: myarr[0], or the entire array myarr?

    So are these definitions actually for the element indexed by index/key 0 being set, not for the array being set?

  3. What is POSIX definition for a shell array being set?

  1. The definition for an array being set is from bash manual:

    An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.

    • Does it mean that an array is set if and only if the number of its elements is greater than zero?

    • Is the following array set, myarr=()?

    • The manual also says

      A parameter is set if it has been assigned a value. The null string is a valid value.

      Since an array is also a parameter, how does the definition of an array being set agree with the definition of a parameter being set?

      For example, myvar="" is set, but is myarr=() set? Has myarr been assigned a value, which is null?

  2. There is a different definition for an array being set from http://unix.stackexchange.com/a/246703/674

    For shells that support arrays, except for yash and zsh that would not report as set array variables unless the element of indice 0 has been set.

    For bash (but not ksh93 nor zsh), for variables of type associative array, that would not report them as set unless their element of key "0" has been set.

    Is this definition incorrect, because an array name without subscription actually refers to the element indexed by index/key 0 instead of referring to the entire array, according to Bash manual

    Referencing an array variable without a subscript is equivalent to referencing with a subscript of 0.

    For example, when applying to an array myarr the usual ways of testing if a variable/parameter is set, which does myarr in ${myarr+1} and [[ -v myarr ]] mean: myarr[0], or the entire array myarr?

    So is this definition actually for the element indexed by index/key 0 being set, not for the array being set?

  3. What is POSIX definition for a shell array being set?

added 55 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
Loading
deleted 15 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
Loading
added 265 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
Loading
added 195 characters in body
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
Loading
Source Link
Tim
  • 106.8k
  • 234
  • 651
  • 1.1k
Loading