views:

42

answers:

2

Want to know what set -A option does in the below command?

 XMLOUTFILE=${XMLOUTDIR}/${TEST_ID}
 set -A FILES "${XMLOUTFILE}" 
A: 

It sets an array value in the shell. This array is named FILES.

The -A will specifically delete the XMLOUTFILE entry, and replace it.

Starkey
+1  A: 

set -A is Korn Shell (ksh) specific (not available in Bash or POSIX SH) and it initializes an array with the specified value(s).

Here's an example:

$ set -A COLORS "red" "green" "blue"
$ print ${COLORS[0]}
red
$ print ${COLORS[1]}
green
$ print ${COLORS[2]}
blue

In your example, ${FILES[0]} is set to $XMLOUTFILE.

Instead of using set -A you can also use for example ARRAY[0]="value" which is more portable.

dandu