zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: b='${a//"/}' and ${(e)b}
Date: Sat, 10 May 2008 13:38:43 +0100	[thread overview]
Message-ID: <20080510123843.GA5560@sc.homeunix.net> (raw)

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


             reply	other threads:[~2008-05-10 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-10 12:38 Stephane Chazelas [this message]
2008-05-10 17:12 ` Bart Schaefer
2008-05-11 16:10   ` Stephane Chazelas
2008-05-10 21:02 ` [PATCH] zmv (Was: b='${a//"/}' and ${(e)b}) Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080510123843.GA5560@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).