Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16616

histexpand in shebang-less script

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Grisha Levit <grishalevit@gmail.com>
Newsgroups gnu.bash.bug
Subject histexpand in shebang-less script
Date Fri, 24 Jul 2020 19:44:08 -0400
Lines 41
Approved bug-bash@gnu.org
Message-ID <mailman.519.1595634263.24492.bug-bash@gnu.org> (permalink)
References <CAMu=Brp0zxz6R9pszEizu-3=HUpYOUOmXvs5h+9o3WcL1UGEDA@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1595634264 19321 209.51.188.17 (24 Jul 2020 23:44:24 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Oj7vZA1wGU8XQRwcebDs8J/C7F//lI962SqhjjZ7HDc=; b=DHeLPYkot5sRkkS6hdtNk8royOXWdCRvDvZ3d16JH73w0B73CDqga1GsAb/WBpSPqO C1f/3L9vdbNN4nGJON8w6eYUPNLB7zUAl3r041K+vgK2AQuiiTn5ed+USKkJ3CT6ajzv FmYw/+7THF/FiMQFP5BsuMhhEwF4qhN+Gl6YIY+xPnPqhplTcJRzu/YxUIL/NdMS4KEx fy6+MDeyB9IlxDAeY2XhHeJ8JynCFR4/UeaW1bngCQOHSKHBj67NuZ2RxCVowadbwici zECEfk83P5PfUOjCvtscEKORsjttsPztZTjpY9heYPj1jvIfdi8Z8ehlQUvf889uOTqK AS2Q==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Oj7vZA1wGU8XQRwcebDs8J/C7F//lI962SqhjjZ7HDc=; b=DDi4mGU+jMitvSxJtE8arx4C75TPllS+Vrctxch6YdJr6zS0AXcHxftFZMYFsu9T0j P45uucQUvVHk2Uo102eqqLigdDNH3Pd5dd0pRCmBlrnvTfVQGFmWXMLod4TkvCB0P8j3 3bfuSKTjhTFqSMO67o6lbHwYfA0U049O5fsbraSf8fZ+YcBpLL8pgWXh2vSdarchknTo 0r5t5SmGktQLNi90FZL2z+uun+ob30JoOyWCzKZFbjbNfZmIUuVOR81uYpklwgxZZEVw QGOIVRA05bGlyQRJ0N0ajiMwVFOaBmZTdNhriPTFwZE357HZ5GElKpEuy7S8Ifkfbcz3 2/bA==
X-Gm-Message-State AOAM533dW24RZUnghac92RtvM7W1W5UydtpSvi0YEo/PIzuieKK1KOVB f90TduA6OkuLIjkXnx0mmJgWb5a2yOyhpflIUBbbw0ZUB+A=
X-Google-Smtp-Source ABdhPJyNbzvJpZca/SGQyIJi2qmKhg6BWsa1XAZR8RkYTBAfr3NM83GWFsytvCHWE0wycBgQKWbXcsjvKIT9G/7m5Oo=
X-Received by 2002:a37:b9c4:: with SMTP id j187mr13232128qkf.174.1595634259406; Fri, 24 Jul 2020 16:44:19 -0700 (PDT)
Received-SPF pass client-ip=2607:f8b0:4864:20::72e; envelope-from=grishalevit@gmail.com; helo=mail-qk1-x72e.google.com
X-detected-operating-system by eggs.gnu.org: No matching host in p0f cache. That's all we know.
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, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAMu=Brp0zxz6R9pszEizu-3=HUpYOUOmXvs5h+9o3WcL1UGEDA@mail.gmail.com>
Xref csiph.com gnu.bash.bug:16616

Show key headers only | View raw


The value of `histexpand' is not reset when executing a shebang-less
script. (Admittedly, this is unlikely to matter since the value of
`history' *is* properly reset.)

$ cat > /tmp/test1.sh <<"EOF"
#!/usr/bin/env bash
echo $-
EOF
$ cat > /tmp/test2.sh <<"EOF"
echo $-
EOF
$ chmod +x /tmp/test1.sh /tmp/test2.sh
$ set -H
$ /tmp/test1.sh
hB
$ /tmp/test2.sh
hBH

Since reset_shell_flags is only called in this circumstance, it seems
that turning off history expansion should be the right thing to do in
that function.

---
 flags.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/flags.c b/flags.c
index 7e301f77..187c2e98 100644
--- a/flags.c
+++ b/flags.c
@@ -366,7 +366,3 @@ reset_shell_flags ()
 #if defined (BANG_HISTORY)
-#  if defined (STRICT_POSIX)
-  history_expansion = 0;
-#  else
-  history_expansion = 1;
-#  endif /* STRICT_POSIX */
+  histexp_flag = 0;
 #endif
--

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

histexpand in shebang-less script Grisha Levit <grishalevit@gmail.com> - 2020-07-24 19:44 -0400

csiph-web