[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shell-script mode vs. quoted apostrophe
From: |
martin rudalics |
Subject: |
Re: shell-script mode vs. quoted apostrophe |
Date: |
Wed, 30 May 2007 11:29:30 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> shell-script mode thinks everything after the quoted apostrophe is
> quoted at least judging from the color.
>
> GNU Emacs 22.0.95.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
2007-03-03 on pacem, modified by Debian
>
> #!/bin/sh -ex
> test $# -eq 3 ||{ echo $0: couldn\'t look it up in $f 1>&2; exit 55;}
> exec pppd user $1 $extra_opts connect \
> "chat -v -f /etc/chatscripts/generic -T $2"
Most shell scripts require that within single quotes _all_ characters
get quoted, including the backslash. Emacs resolves this by removing
the escape property for a backslash whenever it appears before a single
quote due to the following (inherently wrong) specification within
`sh-font-lock-syntactic-keywords':
;; In a '...' the backslash is not escaping.
("\\(\\\\\\)'" 1 ,sh-st-punc)
This strips the escape property from _any_ backslash preceding a single
quote (since it does not render backslashes non-escaping when they are
followed by any other character within single quotes the specification
is obviously wrong, without visible consequences, though). In your case
things go wrong outside a single quote environment: The backslash in
couldn\'t gets punctuation syntax, doesn't escape the subsequent quote,
which consequently starts quoting everything after it ...
I'm afraid that solving this is non-trivial. It could be done by
calling the parser in font-lock's syntactic keyword pass but this would
render font-lock unbearably slow. It should be done in the parser but
I'm not sure whether shell scripts warrant such a modification.