Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@replace weirdness

Oct
92
0
I’m trying to make an esc function for echoing stuff containing special chars without having to use quotes.

Why does
Code:
echo %@replace[^|,^^|,%@replace[^^,^^^^,foo|bar]]
evaluate to
Code:
foo^^|bar
?

It seems to be doing the ^ replacement after doing the | replacement.
Code:
echo %@replace[^|,^^|,foo|bar]
evaluates to
Code:
foo^|bar
as expected. My full esc function works as expected if the ^ replacement is omitted.
Code:
27.6G C:\Users\johnb\tmp> eset /f esc
esc=%@replace[^>,^^>,%@replace[^<,^^<,%@replace[^&,^^&,%@replace[^|,^^|,%$]]]]

27.6G C:\Users\johnb\tmp> echo %@esc[&|<>]
&|<>
(n.b. To enter this function at the command line, double all ^s)
Code:
function esc=`%@replace[^^>,^^^^>,%@replace[^^<,^^^^<,%@replace[^^&,^^^^&,%@replace[^^|,^^^^|,%$]]]]`
 

Similar threads

Back
Top