public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: "Listeria monocytogenes" <listeria@disroot.org>
To: <dash@vger.kernel.org>
Subject: Treat $_ as a special variable
Date: Wed, 22 Oct 2025 14:18:13 +0000	[thread overview]
Message-ID: <DDOWZC8VVBRJ.1451WK7WE6O79@disroot.org> (raw)

Hello,

The current treatment of the $_ variable leads to spilling the last
argument from a command into the environment of the next when dash is
invoked interactively from bash or zsh, as in:

  bash$ dash
  dash$ echo hello
  hello
  dash$ env | grep ^_=
  _=hello

This is because bash exports _=/usr/bin/dash (or whatever the full
pathname used to invoke dash is) into dash's environment, which in turn
sets it to the last argument of the previous command, but as it has been
exported, it spills into the environment of the next command.

Currently, this can be mitigated by executing `unset _` in $ENV, but
this would not be a problem if $_ were treated as a special variable, as
its value in the environment would remain unmodified.

                 reply	other threads:[~2025-10-22 14:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DDOWZC8VVBRJ.1451WK7WE6O79@disroot.org \
    --to=listeria@disroot.org \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox