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

Re: surprise with echo



On Dec 18,  5:24pm, Ray Andrews wrote:
}
} Why should it do that? It's very cool what it permits
} as explained in 'the book' p. 288, but is the above
} part and parcel of that?

The doc spells this out explicitly:

RC_EXPAND_PARAM (-P)
     Array expansions of the form `FOO${XX}BAR', where the parameter XX
     is set to (A B C), are substituted with `FOOABAR FOOBBAR FOOCBAR'
     instead of the default `FOOA B CBAR'.  Note that an empty array
     will therefore cause all arguments to be removed.

} Can that be prevented?

Only by turning off the option, or by doing e.g. ${@:-''} so that the
expansion is the empty string rather than the empty array.

} Is this a feature?

It's how array expansion works in the "rc" shell, which is the source
from which this behavior is borrowed.  There's probably an "rc" list
somewhere where you might get an explanation.



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