Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Quoting problems



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: test_script
Description: Binary data

Attachment: snap-2016.02.16_07:52:44
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author