Operating System - HP-UX
1753785 Members
7668 Online
108799 Solutions
New Discussion

set -A VAR -g reports an error message

 
Jdamian
Respected Contributor

set -A VAR -g reports an error message

Hi

'set -A' is used to declare and fill an array variable.

The following example works fine:

set -A VAR A B "C D"

but this other reports an error message:
set -A VAR -g
/usr/bin/sh: -g: bad option(s)

why '-g' is seen as an option by shell ?
According to manual pages remaining args after variable name are the values to be assigned. But I suspect shell parses them and reports errors because changing character after dash reports other error messages:

set -A VAR -A
/usr/bin/sh: -A: argument expected

The next example sets properly VAR2:
set -A VAR -A VAR2 hello people

The next example sets properly VAR:
set -A VAR '\-A' VAR2

The next example sets no variable:
set -A VAR -

Is this a bug ?

Thanx in advance
1 REPLY 1
Kent Ostby
Honored Contributor

Re: set -A VAR -g reports an error message

Try this:

set -A VAR "\-g"
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"