Your message dated Sun, 13 May 2012 13:51:52 -0500
with message-id <20120513185152.GA30299@burratino>
and subject line Re: bash: quoting breaks when single quotes are used inside of 
double quotes, and placed next to an asterisk
has caused the Debian Bug report #672794,
regarding bash: quoting breaks when single quotes are used inside of double 
quotes, and placed next to an asterisk
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
672794: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672794
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: bash
Version: 4.1-3
Severity: normal

This command works:

  duplicity full -vinfo --dry-run --no-encryption --include /etc/resolv.conf 
--exclude '**' /etc/ file:///tmp/

but when quoting is used to store the exclude option inside a
variable, the variable does not render properly.  There are several
syntactically correct ways to do this, but bash fails to handle all of
them:

  options="--exclude '**'"
  options="--exclude '"\*\*\'
  options=--exclude\ \'\*\*\'
  options="--exclude **"
  options="--exclude \'**\'"

  duplicity full -vinfo --dry-run --no-encryption --include /etc/resolv.conf 
${options} /etc/ file:///tmp/


-- System Information:
Debian Release: 6.0.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bash depends on:
ii  base-files                6.0squeeze5    Debian base system miscellaneous f
ii  dash                      0.5.5.1-7.4    POSIX-compliant shell
ii  debianutils               3.4            Miscellaneous utilities specific t
ii  libc6                     2.11.3-3       Embedded GNU C Library: Shared lib
ii  libncurses5               5.7+20100313-5 shared libraries for terminal hand

Versions of packages bash recommends:
ii  bash-completion               1:1.2-3    programmable completion for the ba

Versions of packages bash suggests:
pn  bash-doc                      <none>     (no description available)

-- no debconf information



--- End Message ---
--- Begin Message ---
notfound 672794 bash/4.1-3
quit

Hi,

anonymous coward wrote:

> but when quoting is used to store the exclude option inside a
> variable, the variable does not render properly.  There are several
> syntactically correct ways to do this, but bash fails to handle all of
> them:
>
>   options="--exclude '**'"
>   options="--exclude '"\*\*\'
>   options=--exclude\ \'\*\*\'
>   options="--exclude **"
>   options="--exclude \'**\'"
>
>   duplicity full -vinfo --dry-run --no-encryption --include /etc/resolv.conf 
> ${options} /etc/ file:///tmp/

This behavior is required by POSIX[1].  A quote character that is the
result of expansion is not a candidate for quote removal, and
parameter expansion occurs before pathname expansion.

Your best bet would be something like this:

        # emulate "git rev-parse --sq-quote"
        sq_quote () {
                result=
                for arg
                do
                        result="$result $(
                                printf '%s' "$arg" |
                                sed -e "s/'/'\\\\''/g" -e "1 s/^/'/" -e "\$ 
s/\$/'/"
                        )"
                done
                printf '%s\n' "$result"
        }

        options=$(sq_quote --exclude '**')
        eval "duplicity ... $options ..."

Or, written more directly:

        options="--exclude '**'"
        eval "duplicity ... $options ..."

Thanks for writing,
Jonathan

[1] http://unix.org/2008edition/


--- End Message ---

Reply via email to