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

Re: Justifying text output



Thorsten Kampe wrote:

> I figured it out: "setopt shwordsplit" made the "extra spaces" and
> "setopt rcexpandparam" made the multiple "[ ok ]". Please advise if
> setting them makes sense - meaning making the life of a zsh non-expert
> easier or more difficult.

Most zsh experts probably set rcexpandparam but not shwordsplit.

Setting shwordsplit makes zsh behave more like other Bourne type
shells. Variables containing spaces are split into separate words when
you expand the variable. Unless you're particularly used to it
working this way, you'll probably find that leaving it unset will make
life easier. If you want something to be split at spaces, it is
generally better to use an array.

rcexpandparam on the other hand tends to make life easier. To see what
it does, try this:

% a=(a b c)
% echo 1${a}2
1a b c2
% setopt rcexpandparam 
% echo 1${a}2	      
1a2 1b2 1c2

Given that you seem to be writing a function or script here, you might
want to consider adding:
  emulate -L zsh
to the top of it. That resets all the options to sane values locally
for the function. That way you don't risk breaking your script if you
change your option settings later.

Oliver



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