From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Max Nikulin Newsgroups: gmane.emacs.bugs Subject: bug#67259: 29.1; shell/term behavior different from other terminal emulators Date: Sun, 30 Jun 2024 16:52:14 +0700 Message-ID: <81d5867b-a9fd-4cef-9f0f-e0a42cd5e309@gmail.com> References: <18be1dbb3c7.10690fc703382635.7777970297366947027@excalamus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26874"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: Ihor Radchenko To: matt@excalamus.com, 67259@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 30 11:53:09 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sNrF7-0006mF-84 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jun 2024 11:53:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNrF2-0000cL-Ia; Sun, 30 Jun 2024 05:53:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNrF0-0000cC-BJ for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 05:53:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNrEz-0002ZW-W5 for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 05:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sNrEz-0005yu-OF for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 05:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Max Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jun 2024 09:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67259 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Matt , bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.171974114222946 (code B ref -1); Sun, 30 Jun 2024 09:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jun 2024 09:52:22 +0000 Original-Received: from localhost ([127.0.0.1]:55150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNrEM-0005y2-8H for submit@debbugs.gnu.org; Sun, 30 Jun 2024 05:52:22 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNrEJ-0005xu-Sc for submit@debbugs.gnu.org; Sun, 30 Jun 2024 05:52:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNrEJ-0000aP-Qt for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 05:52:19 -0400 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNrEI-0001K4-1m for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 05:52:19 -0400 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52ce9ba0cedso3329138e87.2 for ; Sun, 30 Jun 2024 02:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719741136; x=1720345936; darn=gnu.org; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=AW9RTHxdIqO8W67OPIEQ8bxLc1mDtpxThXyh3vqguGQ=; b=KKUuyw4sXjY6eRIZxwL/7vNgzT4mYVE+dSmU7gEdKumvHg0SQl2RWlDunkv1Eu7rNZ Dm9CHXcpQ84zKqyaMqVbHLcsTTRWHXv++yeGdg7av6P95D7DyDAa2W57eN8izWILz+SA xyjcaLKlXDqGkB3ULviko7V/s9sAqA7LIqw5i+WtIObTMpB81Cbu7KF/PBM9jnYvW7Eh Sm0vkU6zrGD0F04A0WhGznnadRKf8WFJQmEm1yn1Ku52uacVYL0MVxkm2HQFZMZ6p9lg LQ0wjBLVQMPF7zDulKXCiJ1ts0A9Yv4ftv1Jkvx1IJf285d/8LJrQNwov7wq6k1XSIWH Swsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719741136; x=1720345936; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AW9RTHxdIqO8W67OPIEQ8bxLc1mDtpxThXyh3vqguGQ=; b=CozxICL5+ESXdZl9FOdDMPR+6tGKTEV7pMz9/a1x63WUR4di8z88lGxMEqW8BxR5Dk 0Wgiu3VyEspF6QB1QMO2zc8PefFy8YislETZsDo0+PmnEXzdsWm1X1kZ7HtEFOYl0FJx /Rh47LPRLQTYtMpQesr8zSvg0ktLZs0qFYMKydiZHsSx4WVkb5hDWt57nUK8LGVIAiqp juIhIPxZ2UUiYQLTl2Y4jJXjdMf0LQEK6oO6MCVOKIF0QxAS0QcJhmxTkPOVn+/RyNKd KQMP6OG/SlkgPG8XHpmiSAdSu8uXDC1UIvW8MI8oNUuDgfoxAT20xbGb18eZZE5lYItV cujQ== X-Forwarded-Encrypted: i=1; AJvYcCXjIe91GlKmJjGEHaceayx+G8JPKuaYk3XnW4Cz1hmymGfJlucGJQrTfKJI18yNmn+HTpDURIIzQiZUys3R0F9fYKKsrdU= X-Gm-Message-State: AOJu0Yzx/oEQFQtXTS4ITU8WVrRdsuU3Qx8Nl9ilz+fVUE7Xkv0rGZ3p wU43gLnwf9aZmlIugzTk8LzFP0Bn8tTdOpcFR71SdG+HXLZrgwPr X-Google-Smtp-Source: AGHT+IG3zShjm82PV1RFZ3NWPl7s4L5zwg+KVev+7bUbv/fgGY2AnMhOS0wNSSy0dqcqaD72fvA4GA== X-Received: by 2002:ac2:4c41:0:b0:52c:df8e:a367 with SMTP id 2adb3069b0e04-52e82705afemr2321640e87.53.1719741135826; Sun, 30 Jun 2024 02:52:15 -0700 (PDT) Original-Received: from [192.168.0.102] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id 2adb3069b0e04-52e7ab1025esm888303e87.88.2024.06.30.02.52.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Jun 2024 02:52:15 -0700 (PDT) Content-Language: en-US, ru-RU In-Reply-To: <18be1dbb3c7.10690fc703382635.7777970297366947027@excalamus.com> Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=manikulin@gmail.com; helo=mail-lf1-x12f.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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288182 Archived-At: On 18/11/2023 16:55, Matt wrote: > I'm helping to maintain Org mode's shell interaction. The following > was reported to the Org list. When I noticed a discussion of dash bug causing difference in comparison to bash for the provided input, I have realized that Org babel shell issue and this emacs bugs are unrelated. This one is specific to interactive sessions. > Emacs M-x shell and M-x term executing in term-line-mode both produce > a different result Likely `shell' and `term' issues should be treated separately and this bug should be cloned. > than expected as compared to terminal emulators > like xterm or xfce4-terminal running Bash. For non-Emacs terminal > emulators, "bar" is echoed. M-x shell and M-x term executing in > term-line-mode do *not* echo "bar". > > To reproduce with M-x shell: > > 1. emacs -Q > 2. M-x shell > 3. Copy the following two lines: > > ssh localhost "echo foo>foo_file" > echo "bar" I think the following allows to eliminate ssh and to demonstrate the issue with purely local commands. (BASH on macOS might be too old) fakessh() { bash -c 'read -t 0.2 -r; printf "fakessh read: %s\n" "$REPLY"'; } fakessh echo next result: fakessh read: echo next instead of fakessh read: next likely expected by users because it is behavior of xterm&Co. since `shell' relies on specific terminal type, to get the same result on pasting whole snippet at once, do in xterm or a similar application TERM=dumb bash With default TERM modern terminal applications and shells have bracketed paste enabled. It is a security measure that allows users to review pasted commands before executing them When bash is running outside of Emacs, it is possible to paste multiple commands into an editor, try C-x C-e in bash prompt. In my opinion, `shell' either should be documented as unsafe with warnings in docstring and manual or some workaround should be implemented, e.g. saving paste text into a temporary file and executing them. > To reproduce with M-x term: > > 1. emacs -Q > 2. M-x term > 3. C-c C-j to switch to term-line-mode Notice that `term' is not affected if `term-line-mode' is not activated. > 4. Copy the following two lines: > > ssh localhost "echo foo>foo_file" > echo "bar" Another option to break xterm that might be closer to `term-line-mode': Create a custom inputrc file, e.g./tmp/disable-paste.inputrc $include /etc/inputrc set enable-bracketed-paste off and run e.g. in xterm INPUTRC=/tmp/disable-paste.inputrc bash The result pasting the bunch of commands at once is fakessh read: echo next I think, input from `term-line-mode' should be treated more closely to bracketed paste. As a final remark, be careful with scripts running commands like ssh or ffmpeg that optionally read stdin. Be explicit with your intentions and either do fakessh "I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!"