From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Quoting problems
Date: Tue, 16 Feb 2016 08:53:05 +0100 [thread overview]
Message-ID: <CAKc7PVDKd1HWgausNPpqzsi0DK+CJp=+LC0tcEa0cDi-4BJmbQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]
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]//\}" = "${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 – so this is a problem.
The test script is:
# To be sourced
for k in _expand; do
echo "if [[ \"\${functions[$k]}\" != ${(qq)functions[$k]} ]]; then
functions[$k]=${(qq)functions[$k]}
fi"
done
I also attach short version of the result:
if [[ "${functions[_expand]}" != ' setopt localoptions nonomatch' ]]; then
functions[_expand]='[[ $#exp -eq 1 && "${exp[1]//\}" =
"${word//\}"(|\(N\)) ]]'
fi
- sourcing this will fail because of the unquoted backslash.
Best regards,
Sebastian Gniazdowski
[-- Attachment #2: test_script --]
[-- Type: application/octet-stream, Size: 164 bytes --]
# To be sourced
for k in _expand; do
echo "if [[ \"\${functions[$k]}\" != ${(qq)functions[$k]} ]]; then
functions[$k]=${(qq)functions[$k]}
fi"
done
[-- Attachment #3: snap-2016.02.16_07:52:44 --]
[-- Type: application/octet-stream, Size: 170 bytes --]
if [[ "${functions[_expand]}" != ' setopt localoptions nonomatch' ]]; then
functions[_expand]='[[ $#exp -eq 1 && "${exp[1]//\}" = "${word//\}"(|\(N\)) ]]'
fi
next reply other threads:[~2016-02-16 7:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 7:53 Sebastian Gniazdowski [this message]
2016-02-16 9:33 ` Peter Stephenson
2016-02-16 10:11 ` Sebastian Gniazdowski
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='CAKc7PVDKd1HWgausNPpqzsi0DK+CJp=+LC0tcEa0cDi-4BJmbQ@mail.gmail.com' \
--to=sgniazdowski@gmail.com \
--cc=zsh-workers@zsh.org \
/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).