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

Modifier substitutions.



This is all a little inconsistent.

% str="Think of a number"
% old=number
% new=word

% print ${str:s%number%$new}
Think of a word
% print ${str:s%$old%$new}
Think of a number
% print "${str:s%number%$new}"
Think of a $new

Substitutions with ${.../.../...} are more consistent, though there is
something a little odd with quoting in that case.  For example,

% str='#Think of a number'
% old='#Think'
% new='Despair'
% print ${str/$old/$new}
#Think of a number
% print ${str/\\$old/$new}
Despair of a number

The `#' is being interpreted as an anchor at the head of the string even
when buried inside $old.  I have a feeling that wasn't my intention.

pws



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