Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:from:date:message-id:subject:to:content-type;
        bh=tXWLWOQKHI6LvzgboblaM1MwcyUaqMS2vGsHsOpiwqo=;
        b=IWFFfH1QBKnso0FH6thRW0hpNnCHRldPRN5THfr1t3NM5HCbmIEhwI44uSuXG+gJO+
         UWx4040nAhO/VmzacQxvZ4U73VEznqoM9Z+sBeOR+Iwm7/8u3S4hg3sJBDCGbUHfRIoN
         w9xT2LbdEvewEWBxT8C8NE6/eJa+RyPQ6LrpBwPZNjBMMSH68MRTaAcsxqjYfJYCyHoL
         0QM6FjsbpYRvW4QS6I0+3YBBr+z3JvXtzfQhfoU06ZqVvU0mGnJnXRrkvZeesWkt3FnB
         cSXo0RVb/G17lL2FQKJTBNNDcbEnqQmgqVJrnsGELLRyDYIID6bVEAnMckbuuEXdu9qD
         eMcA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:from:date:message-id:subject:to
         :content-type;
        bh=tXWLWOQKHI6LvzgboblaM1MwcyUaqMS2vGsHsOpiwqo=;
        b=kUIAfkZXhYLS8tJ/kkh6aXbD3NFkXRz41YHEdC9f9nTkcUo0Sdp4jGiOst0kYN/JVF
         9gZaL/QD4hoVaMxw+/RgpfetgxSellq2Nsia3XNUwhfTwgL6VkBMJ/flaCTIIbCFdhrc
         fK8igj1TSf3LmgJ2ie9E5CQfX12JmtiMPUvIOglLGismAbDP8UjbaSWDX+IVAYiDRyU2
         e4R/SD6jJdsiQ2peAKuiIncPtqQ2aW2PSb0aH3xwT2/VafgHJeotmSFKycVVDT9Fm74M
         JfTqF+6DjLPDcOcUQsc/HU6DZNC3usSxczlIobBO46dUwz2d3nMNHAg3u5bZapo9YHA9
         LhDQ==
X-Gm-Message-State: AG10YOTRFk7jxq9ixpzHBohZSkYIx0V33kXpSCB7VFjGaEhfw6sy6nBZeKDr5UOmI5mtqIUDudV9OzP7eBEQGg==
X-Received: by 10.25.162.7 with SMTP id l7mr9064812lfe.129.1455609205016; Mon,
 15 Feb 2016 23:53:25 -0800 (PST)
MIME-Version: 1.0
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 16 Feb 2016 08:53:05 +0100
Message-ID: <CAKc7PVDKd1HWgausNPpqzsi0DK+CJp=+LC0tcEa0cDi-4BJmbQ@mail.gmail.com>
Subject: Quoting problems
To: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: multipart/mixed; boundary=001a113db2f69965ef052bde6d79
X-Seq: zsh-workers 37992

--001a113db2f69965ef052bde6d79
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello,
# source test_script > a
# source ./a
./a:156: unmatched "
./a:157: invalid function definition


It's about following line:
[[ $#exp -eq 1 && "${exp[1]//\}" =3D "${word//\}"(|\(N\)) ]]

The first and second backslash aren't quoted and cause the two '{' to
be unbound. Other quoting styles (q, qqq, qqqq) also fail in general
(with e.g. parse errors, also with an 'unmatched "'). I think that
quoting means: content can be anything, special characters will be
taken care of =E2=80=93 so this is a problem.

The test script is:

# To be sourced
for k in _expand; do
    echo "if [[ \"\${functions[$k]}\" !=3D ${(qq)functions[$k]} ]]; then
        functions[$k]=3D${(qq)functions[$k]}
    fi"
done

I also attach short version of the result:
if [[ "${functions[_expand]}" !=3D '      setopt localoptions nonomatch' ]]=
; then
        functions[_expand]=3D'[[ $#exp -eq 1 && "${exp[1]//\}" =3D
"${word//\}"(|\(N\)) ]]'
fi

- sourcing this will fail because of the unquoted backslash.


Best regards,
Sebastian Gniazdowski

--001a113db2f69965ef052bde6d79
Content-Type: application/octet-stream; name=test_script
Content-Disposition: attachment; filename=test_script
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ikp3qzq40

IyBUbyBiZSBzb3VyY2VkCmZvciBrIGluIF9leHBhbmQ7IGRvCiAgICBlY2hvICJpZiBbWyBcIlwk
e2Z1bmN0aW9uc1ska119XCIgIT0gJHsocXEpZnVuY3Rpb25zWyRrXX0gXV07IHRoZW4KICAgICAg
ICBmdW5jdGlvbnNbJGtdPSR7KHFxKWZ1bmN0aW9uc1ska119CiAgICBmaSIKZG9uZQo=
--001a113db2f69965ef052bde6d79
Content-Type: application/octet-stream; name="snap-2016.02.16_07:52:44"
Content-Disposition: attachment; filename="snap-2016.02.16_07:52:44"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ikp3qzqo1

aWYgW1sgIiR7ZnVuY3Rpb25zW19leHBhbmRdfSIgIT0gJwlzZXRvcHQgbG9jYWxvcHRpb25zIG5v
bm9tYXRjaCcgXV07IHRoZW4KICAgICAgICBmdW5jdGlvbnNbX2V4cGFuZF09J1tbICQjZXhwIC1l
cSAxICYmICIke2V4cFsxXS8vXH0iID0gIiR7d29yZC8vXH0iKHxcKE5cKSkgXV0nCiAgICBmaQo=
--001a113db2f69965ef052bde6d79--

