Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    problem to initialize ksh array when first element includes hyphen


    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

  2. #2
    how about this:
    set +A allArgs

  3. #3

    here is another solution(in case you dont know what is the index for array)

    set -A allArgs -- -all
    set -A allArgs -- ${allArgs[@]} -date

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts