Subject: Re: bug#18756: 24.4; shell-script-mode does wrong indentation

From: Glenn Morris <[email-masked]>
Date: Tue, 06 Jan 2015 13:55:17 -0500

Version: 24.5

Peter Oliver wrote:

> I can reproduce this when electric-indent-mode is on and sh-set-shell
> is run for a csh-family shell.

Thanks for this vital clue.
I installed the following, which seems to fix it.

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index d79b387..4700324 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2477,7 +2475,8 @@ Lines containing only comments are considered empty."
 		    (current-column)))
 	current)
     (save-excursion
-      (indent-to (if (eq this-command 'newline-and-indent)
+      (indent-to (if (or (eq this-command 'newline-and-indent)
+                         (and electric-indent-mode (eq this-command 'newline)))
 		     previous
 		   (if (< (current-column)
 			  (setq current (progn (back-to-indentation)