zsh-workers
 help / color / mirror / code / Atom feed
* Quoting problems
@ 2016-02-16  7:53 Sebastian Gniazdowski
  2016-02-16  9:33 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-02-16  7:53 UTC (permalink / raw)
  To: Zsh hackers list

[-- 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-16 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16  7:53 Quoting problems Sebastian Gniazdowski
2016-02-16  9:33 ` Peter Stephenson
2016-02-16 10:11   ` Sebastian Gniazdowski

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).