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

Re: b='${a//"/}' and ${(e)b}



On May 10,  1:38pm, Stephane Chazelas wrote:
}
} $ a='a"b'
} $ b='${a//"/}'
} $ echo ${(e)b}

(etc.)

If you use

$ echo ${(Xe)b}

Then you'll see that zsh burps "parse error" on nearly every one of those
expressions.  Without the (X) flag the error is silently ignored and the
expansion returns nothing.  (Perhaps zmv should use (X).)

Now, as to why it's hard to quote a double quote within a // replacement
when using the (e) flag, I'm not sure what to say except that the parsing
rules for all those nested levels of sometimes-implicit quoting get a bit
arcane.

} How would I do?

$ c='"'
$ b='${a//$c/}'
$ print ${(Xe)b}

Which does work for zmv:

$ zmv -n '*"*' '${f//$c/}'
mv -- a\"b ab

Or you can do this:

$ zmv -n '*"*' '$f:gs/"//'
mv -- a\"b ab

The parsing rules for :s are a lot simpler than those for ${...}.



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