Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Modifier substitutions.
- X-seq: zsh-workers 10533
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Modifier substitutions.
- Date: Thu, 06 Apr 2000 10:15:50 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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