GNU bug report logs - #81973
31.1; Deficiencies of the ~/.emacs_SHELLNAME mechanism

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Augusto Stoffel <arstoffel@HIDDEN>; dated Fri, 2 Oct 2026 11:22:08 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Oct 2026 11:21:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 07:21:42 2026
Received: from localhost ([127.0.0.1]:54098 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1xCbKc-000503-2G
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 07:21:42 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:47192)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <arstoffel@HIDDEN>)
 id 1xCbKT-0004zC-Pd
 for submit <at> debbugs.gnu.org; Fri, 02 Oct 2026 07:21:33 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1xCbKN-0007Lk-6r
 for bug-gnu-emacs@HIDDEN; Fri, 02 Oct 2026 07:21:23 -0400
Received: from mail-wr2-x0e.google.com ([2a00:1450:4864:30::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1xCbKL-0002ZG-K4
 for bug-gnu-emacs@HIDDEN; Fri, 02 Oct 2026 07:21:22 -0400
Received: by mail-wr2-x0e.google.com with SMTP id
 ffacd0b85a97d-48b01c41135so1967118f8f.0
 for <bug-gnu-emacs@HIDDEN>; Fri, 02 Oct 2026 04:21:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1790940079; x=1791544879; darn=gnu.org;
 h=content-type:mime-version:message-id:date:subject:to:from:from:to
 :cc:subject:date:message-id:reply-to:content-type;
 bh=TjlsfOCgooU+NmgYj2+OAEPm5BhfAoydcHY4NGNY/9Q=;
 b=Ml/1o/PAFEdZFXHfv84o8+24fzh8CGiwRBlhIYaoKJYYu9f3U2eMWIQUqjKMXfLQGT
 FN7j2CH170eZ6OrTKel6hKeounExR0lHSa5OtPxwWApCslr/eLyu/TEqw+L2zxqUSj6H
 XTyHEMXw/ngywwBM2ckVDcA2BpPAK4Vtw840Wn6mnvQKnRuhGuzNcrDQu6iNOPGXf5+M
 toDLr6jl4jOBrLuk0UNbtcXR2+1owhSBSaS8x3qRcp2BjJCq7s/7HaKEZA1ajb/hv/lB
 zQDazqbFg0cEERsdKU/HJ85iUIUgZPrh1yN4utIZLodMGxPjFn1/t8/8r6uLr21601PY
 XFLw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20260707; t=1790940079; x=1791544879;
 h=content-type:mime-version:message-id:date:subject:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
 :content-type;
 bh=TjlsfOCgooU+NmgYj2+OAEPm5BhfAoydcHY4NGNY/9Q=;
 b=eclLyicEKBRlI2QcwP/96E0B4pxMFLHQogbnNQvA7WipMIvOhZ7bXiBlQSgXgzdMOL
 EGLtZB0SluSnukcEdDZwc5ufSWMlaGk+0ZvnLTmUGspFriEV/fvQyaCGw3lKzfeeXIaS
 CeNAliuUQbVv/2t3+OHHQDGee3Prxf+FlD6tRc2s6ktD3Pvkv3Clvd4pHRnSYRuC//YG
 R7ZmqstM4uWnJUYuMl6aVw2EId0g8HZBR2PKG01wAS9Wh+1r9etdqYBAlmqjIDXNA5Hl
 NsPG6vg6kV6B0r1cy3XpJQVt/pH6Wx2MBC9VKwCAVsDAbvO2sEIQcyD53SWD3UwjmINg
 L6cQ==
X-Gm-Message-State: AFuF++lgSc1DtdwHJQiZjdRaEWVUI9UTj4CJpp5YtgS+xeCBmYPOBxc1
 po8NmNZeKGwgsTin8kzHuKrljp+Z4e6B4+mMlkw9idevA+5QrGf3WDfwwLMFzA==
X-Gm-Gg: AYBFou0TwVQ24bE1OyBseEq9WtiEoVZ0lZzqdGGdaYq6saiWewpdEAxZ1C0stnZ4NTo
 H202Jk4Xk4Vg2tdYoYfKVoaAmrbDLVmHIRJm9ZLwgs84sNSRsmPR83JmFsZxUKvVwRKKE1VzY9s
 ayzls1VZiihbidI3tIfcotiPHOMQGjEFAYELn0t3u4OOMB+E4JtFXHk0c36zukH7D2qp3Tpck/Y
 69vJLGxDFbe8ORZA64FLfP4yAZpUjMueCMtG0UGkvApszqi/e0TjNraRTO9PyBS1RIPDM2BDz3p
 TPoyDlzdaHYzStI0L27VRmdSLW3hovjuojbLFzy9Pvbe3Z7qpOljT1Ee4TI8HAu0JYj9SrE0Ejv
 gV9ofA4rZI8jhMubg1q40YhmZ/FolAGmTFedJXZO2Bq9cycgB0dLYYTSu1xiLY2GqD6BrVxAPjo
 62WB8BD2FJQxMDnmVHy94sIB5yJOC6WsnJqX1GvlBcY8DGN0r0E1qeT0rnWYk4gQgyzQqEDw==
X-Received: by 2002:a05:600c:1e0f:b0:49e:6249:268b with SMTP id
 5b1f17b1804b1-4a027697ef2mr39492545e9.32.1790940079261; 
 Fri, 02 Oct 2026 04:21:19 -0700 (PDT)
Received: from ars3 ([2a02:8109:8aa6:9c00::763f])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4a0280dc6e7sm94008675e9.15.2026.10.02.04.21.18
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 02 Oct 2026 04:21:18 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 31.1; Deficiencies of the ~/.emacs_SHELLNAME mechanism
X-Debbugs-Cc: Michael Albinus <michael.albinus@HIDDEN>
Date: Fri, 02 Oct 2026 13:21:17 +0200
Message-ID: <87zeww8i1e.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2a00:1450:4864:30::e;
 envelope-from=arstoffel@HIDDEN; helo=mail-wr2-x0e.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  As discussed in a tangent of bug#81953,
 the ~/.emacs_SHELLNAME
 mechanism (info "(emacs) Interactive Shell") has some usability issues: -
 Each line from that file are added to the command history, each time a shell
 is started. - You can't change the first prompt using it. - Generally, it
 relies on prompt detection, which is fragile. 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (arstoffel[at]gmail.com)
 1.0 FORGED_GMAIL_RCVD      'From' gmail.com does not match 'Received'
 headers
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

As discussed in a tangent of bug#81953, the ~/.emacs_SHELLNAME mechanism
(info "(emacs) Interactive Shell") has some usability issues:

- Each line from that file are added to the command history, each time a
  shell is started.
- You can't change the first prompt using it.
- Generally, it relies on prompt detection, which is fragile.

Perhaps there's a better way to achieve the desired effect.

If we restrict to POSIX shells running over a PTY, then here's an idea:

--8<---------------cut here---------------start------------->8---
(defun shell-source-file (file)
  (interactive "fSource file: ")
  (when-let ((proc (get-buffer-process (current-buffer))))
    (with-temp-buffer
      (insert-file-contents file)
      (process-send-string proc " printf '\\r' && . /dev/stdin\n")
      (accept-process-output proc 1)
      (process-send-region proc (point-min) (point-max))
      (process-send-eof proc))))

(add-hook 'shell-mode-hook (lambda ()
                             (accept-process-output proc 1)
                             (shell-source-file "~/test.sh")))
--8<---------------cut here---------------end--------------->8---

If the above function worked without the two calls to
accept-process-output, then I'd say this would be a very clean trick.
On my machine, with Linux and bash, that actually is the case when bash
is running without readline.

If I enable readline by adding 'set +x emacs' to my ~/.bashrc, then (and
only then) the two calls to accept-process-output become necessary.
Unfortunately it's a race condition, not sure why and whether it can be
avoided.




Acknowledgement sent to Augusto Stoffel <arstoffel@HIDDEN>:
New bug report received and forwarded. Copy sent to michael.albinus@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to michael.albinus@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#81973; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 2 Oct 2026 11:30:12 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.