Subject: bug#24838: 26.0.50; Parse error in certain shell scripts

From: Philipp Stephani <[email-masked]>
Date: Mon, 31 Oct 2016 16:23:16 +0100

Visit the following file in shell-script-mode:

#!/bin/bash

a="
("

if b; then
  c
else
  d
  # '
fi

Now move point inside 'fi', and run M-x show-paren-mode.  You'll notice
that the 'fi' is marked as syntax error, and 'if' isn't highlighted,
indicating that the construct wasn't parsed correctly.
Now run C-c ?.  This will cause an error "smie-indent-keyword: Wrong
type argument: number-or-marker-p, noindent".  The stack trace is

(wrong-type-argument number-or-marker-p noindent)
  smie-indent--rule(:before "fi" nil (t 50 "'") 50)
  smie-indent-keyword()
  run-hook-with-args-until-success(smie-indent-keyword)
  smie-indent-calculate()
  smie-config--get-trace()
  smie-config-show-indent()
  sh-show-indent(nil)
  funcall-interactively(sh-show-indent nil)
  call-interactively(sh-show-indent nil nil)
  command-execute(sh-show-indent)

Now hit M-> and hit RET.  The indentation now inserted will be
completely off.
My suspicion is that this might be a result of
`open-paren-in-column-0-is-defun-start'.  I guess that variable should
be set to nil in shell-script-mode, as parens in column 0 can never
start a function in shell scripts.

In GNU Emacs 26.0.50.14 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
 of 2016-10-31 built on locahost
Repository revision: 8e7b1af1d708dcf41695cf3fbeff9d35cdb8e5b6
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:	Ubuntu 14.04 LTS

Recent messages:
Setting up indent for shell type bash
Indentation variables are now local.
Indentation setup for shell type bash
Error: (wrong-type-argument number-or-marker-p noindent) [3 times]
Show-Paren mode enabled
s-h is undefined
Type C-x 1 to delete the help window, C-M-v to scroll help.
mwheel-scroll: Beginning of buffer [2 times]
Saving file /tmp/aa.sh...
Wrote /tmp/aa.sh

Configured using:
 'configure --with-modules --enable-checking
 --enable-check-lisp-object-type 'CFLAGS=-ggdb3 -O0''

Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell-script

Minor modes in effect:
  show-paren-mode: t
  sh-electric-here-document-mode: t
  tooltip-mode: t
  global-eldoc-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
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compile cl-extra cconv dired dired-loaddefs format-spec
rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils pp wid-edit descr-text help-mode easymenu
cl-loaddefs pcase cl-lib cus-start cus-load paren sh-script smie
executable time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded 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 inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 201926 10234)
 (symbols 48 33043 0)
 (miscs 40 361 231)
 (strings 32 75698 7320)
 (string-bytes 1 1792773)
 (vectors 16 16013)
 (vector-slots 8 535350 19029)
 (floats 8 194 57)
 (intervals 56 314 11)
 (buffers 976 14)
 (heap 1024 50030 1243))

-- 
Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Diese E-Mail ist vertraulich.  Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge.  Vielen Dank.

This e-mail is confidential.  If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments.  Thanks.