From 1abbe4e53150562ad7731510672fca35374f1a89 Mon Sep 17 00:00:00 2001
From: Chong Yidong <cyd@stupidchicken.com>
Date: Sun, 16 Aug 2009 14:04:25 +0000
Subject: [PATCH] * progmodes/sh-script.el (sh-maybe-here-document): Avoid
 inserting another heredoc if the user adds another < (Bug#3226).

---
 lisp/ChangeLog              | 3 +++
 lisp/progmodes/sh-script.el | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 955521bb8a0..2cdb28ddc3b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
 2009-08-16  Chong Yidong  <cyd@stupidchicken.com>
 
+	* progmodes/sh-script.el (sh-maybe-here-document): Avoid inserting
+	another heredoc if the user adds another < (Bug#3226).
+
 	* mwheel.el (mouse-wheel-down-event, mouse-wheel-up-event): Don't
 	initialize based on window-system (Bug#4124).
 
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index c5ca9bbd9c8..d948f9f61f9 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -3749,7 +3749,7 @@ The document is bounded by `sh-here-document-word'."
   (interactive "*P")
   (self-insert-command (prefix-numeric-value arg))
   (or arg
-      (not (eq (char-after (- (point) 2)) last-command-event))
+      (not (looking-back "[^<]<<"))
       (save-excursion
 	(backward-char 2)
 	(sh-quoted-p))
-- 
2.39.5