In order to remind myself when I try to use
shopt in Zsh instead of
setopt, I created the following alias, testing it first at a shell prompt:
$ alias shopt='echo "You\'re looking for setopt. This is Z shell, man, not Bash."'
Despite the outer single quotes matching and the inner double quotes matching, and the apostrophe being escaped, I was prompted to finish closing the quotes with:
dquote > _
What's going on?
It appeared that the escaping was being ignored, or that it needed to be double-escaped because of multiple levels of interpretation... So, just to test this theory, I tried double-escaping it (and triple-escaping it, and so on) all the way up until:
alias shopt='echo "You\\\\\\\\\\\\\\\\\\\\\\'re looking for setopt. This is Z shell, man, not Bash." '
and never saw any different behavior. This makes no sense to me. What kind of weird voodoo is preventing the shell from behaving as I expect?
The practical solution is to not use quotes for
echo, since it doesn't really need any, and to use double quotes for
alias, and to escape the apostrophe so it is ignored when the text is
echoed. Then all of the practical problems go away.
Can you help me? I need resolution to this perplexing problem.