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

Re: nohistsubstpattern and :s//



On Mon, Jul 6, 2015 at 10:51 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jul 6,  9:49am, Peter Stephenson wrote:
> }
> } I don't think it's *that* much of a problem that the modifiers behave
> } differently in contexts that are themselves intrinsically rather
> } different.
[...]
> No way to quote "/" when using in a glob qualifier:
>
> torch% ls *a*
> config.modules.local  config.status  Makefile  stamp-h
> torch% b=/
> torch% print *a*(:s/a/$b/)
> config.modules.locl config.sttus Mkefile stmp-h
> torch% b=X
> torch% print *a*(:s/a/$b/)
> config.modules.locXl config.stXtus MXkefile stXmp-h
>
> (Perhaps ${(b)...} should put backslashes in front of slashes? But two
> backslashes are needed:
>
> torch% print *a*(:s/a/\//)
> config.modules.locl config.sttus Mkefile stmp-h
> torch% print *a*(:s/a/\\//)
> config.modules.loc/l config.st/tus M/kefile st/mp-h
>
> so maybe this just calls for using a different delimiter.)

You can use any character instead of a /, even a literal NUL
character, so it's not really something ${(b)...} can/should know
about, I think?

% a=f/o/o/; echo $a:gs^@/^@_^@
f_o_o_
% a=moo; echo $a:spoopypants
myants
% echo ..(:gs^@.^@hello\\^@there^@)|cat -v
hello^@therehello^@there

-- 
Mikael Magnusson



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