Results 1 to 3 of 3
Hi
I'm trying to create an array with variable including hyphen
but ksh refuses the first element
(actually I replaced at by * since forum rules restricts URL embedded..)
set ...
- 07-19-2011 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 5
problem to initialize ksh array when first element includes hyphen
Hi
I'm trying to create an array with variable including hyphen
but ksh refuses the first element
(actually I replaced at by * since forum rules restricts URL embedded..)
set -A allArgs
set +A allArgs ${allArgs[*]} -all
set +A allArgs ${allArgs[*]} -date
set +A allArgs ${allArgs[*]} test
./test.ksh[11]: -all: bad option(s)
It happens only when first element is like this:
set +A allArgs ${allArgs[*]} all
set +A allArgs ${allArgs[*]} -date
set +A allArgs ${allArgs[*]} test
print "Array is: ${allArgs[*]}"
Array is: all -date test
- 07-19-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
how about this:
Code:set +A allArgs allArgs[1]='-all' allArgs[2]='-date' allArgs[3]='test'
- 07-20-2011 #3Just Joined!
- Join Date
- Aug 2009
- Posts
- 5
10x
here is another solution(in case you dont know what is the index for array)
set -A allArgs -- -all
set -A allArgs -- ${allArgs[@]} -date


Reply With Quote