]> code.delx.au - gnu-emacs/commitdiff
* lisp/progmodes/sh-script.el (sh--inside-noncommand-expression):
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Oct 2012 03:10:25 +0000 (23:10 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 31 Oct 2012 03:10:25 +0000 (23:10 -0400)
Rename from sh--inside-arithmetic-expression, handle more cases.

Fixes: debbugs:11263
lisp/ChangeLog
lisp/progmodes/sh-script.el
test/indent/shell.sh

index 8f4f5153747dad4dfeacd8d8891283d5749f2c99..88ea199cd20cf7d13f0c29d917075e0a765c9c7a 100644 (file)
@@ -1,5 +1,9 @@
 2012-10-31  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * progmodes/sh-script.el (sh--inside-noncommand-expression):
+       Rename from sh--inside-arithmetic-expression, handle more cases
+       (bug#11263).
+
        * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
        (sh-font-lock-open-heredoc): Use it (bug#12770).
 
index c57468bf52ffba3fb15781b40a3cb830fa9fad0f..5af14e51f49de4d39858e5696a5a4d22802c72f9 100644 (file)
@@ -940,14 +940,16 @@ See `sh-feature'.")
     (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
             sh-escaped-line-re "\\(\n\\)")))
 
-(defun sh--inside-arithmetic-expression (pos)
+(defun sh--inside-noncommand-expression (pos)
   (save-excursion
     (let ((ppss (syntax-ppss pos)))
       (when (nth 1 ppss)
         (goto-char (nth 1 ppss))
-        (and (eq ?\( (char-after))
-             (eq ?\( (char-before))
-             (eq ?\$ (char-before (1- (point)))))))))
+        (pcase (char-after)
+          ;; $((...)) or $[...] or ${...}.
+          (`?\( (and (eq ?\( (char-before))
+                     (eq ?\$ (char-before (1- (point))))))
+          ((or `?\{ `?\[) (eq ?\$ (char-before))))))))
 
 (defun sh-font-lock-open-heredoc (start string eol)
   "Determine the syntax of the \\n after a <<EOF.
@@ -958,7 +960,7 @@ be indented (i.e. a <<- was used rather than just <<).
 Point is at the beginning of the next line."
   (unless (or (memq (char-before start) '(?< ?>))
              (sh-in-comment-or-string start)
-              (sh--inside-arithmetic-expression start))
+              (sh--inside-noncommand-expression start))
     ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic
     ;; font-lock keywords to detect the end of this here document.
     (let ((str (replace-regexp-in-string "['\"]" "" string))
index 0636e62a062523f6dee08301e5fc9abc0572731b..6f3447c3aa943910dd12faecae71c5f5194814aa 100755 (executable)
@@ -9,6 +9,11 @@ echo -n $(( 5 << 2 ))
 # This should not be treated as a heredoc (bug#12770).
 2
 
+foo='bar<<'                     # bug#11263
+echo ${foo%<<aa}                # bug#11263
+echo $((1<<8))                  # bug#11263
+echo $[1<<8]                    # bug#11263
+
 declare -a VERSION
 for i in $(ls "$PREFIX/sbin") ; do
     echo -e $N')' $i