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

Re: Can this be done with an array parameter?



On Feb 19,  5:46pm, DervishD wrote:
}
}     cat filename | while read line
}     do
}         info=($info $line)
}     done
} 
}     This effectively store every line as a separate item in the array
} parameter, which surprises me.  [...]
} 
} Zsh is reading my mind or so. Can anybody explain?

I note that PWS didn't bother to explain. :-)

Unless the SH_WORD_SPLIT option is set, variable references like $info
and $line aren't exactly quoted, but they aren't split up at spaces
either.  $info is an array, so it acts (almost) like "${info[@]}", but
$line is a scalar, so it acts (almost) like "$line".

The "almost" part has to do with what happens to array elements or
variables whose value is the empty string, and unset variables.  They
disappear entirely from the expanded command line rather than remaining
there as a quoted empty string.



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