Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

how to force scalar to be an array?



Sorry, guys, one more question:

I've got this:
  result=`some_proggie`
  first_word=${${=result}[1]}
  rest_words=${${=result}[2,-1]}
But this works as expected only if result contains more than one word.

An example:
 $ result="foo bar baz"
 $ print -c ${${=result}[1]}
 foo

 $ result="foo"             
 $ print -c ${${=result}[1]}
 f

I also tried this:
 $ print -c ${${(@)=result}[1]}
 f

What am I doing wrong here?

Oh, boy what a day!  :-(
 Andy.

-- 
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Warning: This email, when printed on paper, has sharp edges.
 Handle with care or serious injury may result.



Messages sorted by: Reverse Date, Date, Thread, Author