# HG changeset patch
# User Simon Marshall <simon@gnu.org>
# Date 881264879 0
# Node ID 6cb3b9732db5dffebbc43f09d6e1b5880cf31647
# Parent  28110a85d23e1eadac83438d6d4e91bcce6831a8
Deal with `#'s in variable references.

diff -r 28110a85d23e -r 6cb3b9732db5 lisp/progmodes/sh-script.el
--- a/lisp/progmodes/sh-script.el	Thu Dec 04 17:45:22 1997 +0000
+++ b/lisp/progmodes/sh-script.el	Thu Dec 04 19:47:59 1997 +0000
@@ -628,7 +628,14 @@
 
 (defconst sh-font-lock-syntactic-keywords
   ;; Mark a `#' character as having punctuation syntax in a variable reference.
-  '(("\\$[({]?\\(#\\)" 1 (1 . nil))))
+  ;; Really we should do this properly.  From Chet Ramey and Brian Fox:
+  ;; "A `#' begins a comment when it is unquoted and at the beginning of a
+  ;; word.  In the shell, words are separated by metacharacters."
+  ;; To do this in a regexp would be slow as it would be anchored to the right.
+  ;; But I can't be bothered to write a function to do it properly and
+  ;; efficiently.  So we only do it properly for `#' in variable references and
+  ;; do it efficiently by anchoring the regexp to the left.
+  '(("\\${?[^}#\n\t ]*\\(##?\\)" 1 (1 . nil))))
 
 ;; mode-command and utility functions