Subject: 24.4.50; bad shell-script-mode indentation due to ^[{([] in a here document

From: Ian Kelling <[email-masked]>
Date: Tue, 15 Jul 2014 15:20:29 -0700

emacs -Q the following files, then use indent region on the whole buffer:
(indent-region (point-min) (point-max)) Similar indent commands will work the
same. This is how they get indented:

#!/bin/bash
if true; then
    true <<'EOF'
[ line beginning with one of [{( 
EOF
fi

if true; then
    true
    # comment containing a single quote 'true
           fi
            true

The true commands could be other things, they are just an example. I assume the
if statements could be other things which create indents. The final fi and
anything beyond it get bad indenting that is determined by the quote in the
first quote from 'EOF' Another variation of this bug:

#!/bin/bash
if true; then
    true <<EOF
[ line beginning with one of [{( 
EOF
fi

if true; then
    true
    # comment containing a single quote 'true
                                        fi
                                         true

The final fi and beyond's indenting is determined by the quote in 'true.  

In GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.9)
 of 2014-07-14 on treetowl
Repository revision: 117533 [email-masked]
Windowing system distributor `Fedora Project', version 11.0.11404000
Configured using:
 `configure --enable-link-time-optimization 'CFLAGS=-std=gnu99 -g3 -O2''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Shell-script

Minor modes in effect:
  sh-electric-here-document-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
M-x r e p o r t - b u g <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
r has auto save data; consider M-x recover-this-file
Setting up indent for shell type bash
Indentation variables are now local.
Indentation setup for shell type bash

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util help-fns mail-prsvr mail-utils sh-script smie
executable time-date tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 83313 7281)
 (symbols 48 18389 0)
 (miscs 40 39 124)
 (strings 32 12921 4377)
 (string-bytes 1 335173)
 (vectors 16 10129)
 (vector-slots 8 404842 13811)
 (floats 8 68 68)
 (intervals 56 193 1)
 (buffers 960 12)
 (heap 1024 35157 980))