Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
b='${a//"/}' and ${(e)b}
- X-seq: zsh-workers 24987
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: b='${a//"/}' and ${(e)b}
- Date: Sat, 10 May 2008 13:38:43 +0100
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Hiya,
$ a='a"b'
$ b='${a//"/}'
$ echo ${(e)b}
$ b='${a//\"/}'
$ echo ${(e)b}
$ b='${a//\\"/}'
$ echo ${(e)b}
$ b='${a//\\\"/}'
$ echo ${(e)b}
$ b='${a//["]/}'
$ echo ${(e)b}
$ b='${a//[a]/}'
$ echo ${(e)b}
"b
$ echo "${a//"/}"
dquote braceparam>
$ echo "${a//\"/}"
ab
$ b='${a//["]/}'
$ echo ${(eq)b}
$\{a//\[\"\]/\}
$ echo ${(qe)b}
$\{a//\[\"\]/\}
How would I do?
I came accross the problem when trying:
zmv '*"*' '${f//"/}'
[...]
+zmv:42> pat='*"*'
+zmv:43> repl='${f//"/}'
+zmv:44> shift 2
+zmv:45> [[ -z '' ]]
+zmv:47> tmpf=/tmp/zshzmv5557
+zmv:48> print -P %N
+zmv:49> myname=zmv
+zmv:50> rm -f /tmp/zshzmv5557
+zmv:51> action=mv
+zmv:52> [[ mv != '(cp|mv|ln)' ]]
+zmv:58> [[ -n '' ]]
+zmv:63> [[ -n '' || -n '' ]]
+zmv:91> [[ -n '' ]]
+zmv:96> [[ '*"*' == '(#b)(*)((**##/))(*)' ]]
+zmv:107> fpat='*"*'
+zmv:109> files=( 'a"' )
+zmv:110> [[ -n '' ]]
+zmv:111> errs=( )
+zmv:112> f=a"
+zmv:114> [[ '*"*' == '(#b)(*)(**##/)(*)' ]]
+zmv:118> [[ -e 'a"' && 'a"' == '(#b)*"*' ]]
+zmv:119> set -- ''
g=${(e)repl} +zmv:120> g=''
+zmv:121> [[ -z '' ]]
+zmv:123> errs=( '`a"'\'' expanded to an empty string' )
+zmv:135> from[$g]='a"'
+zmv:136> to[$f]=''
+zmv:138> (( 1 ))
+zmv:140> print -P '%N: error(s) in substitution:'
zmv: error(s) in substitution:
+zmv:141> print -l '`a"'\'' expanded to an empty string'
`a"' expanded to an empty string
+zmv:142> return 1
BTW, shouldn't it be "print -rl -- $errs >&2"?
And -r added to all those "print"s?
It might be a good idea also to use some ${(V)var} when
stdout/stderr is a tty.
Best regards,
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author