unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Milan Zimmermann <milan.zimmermann@gmail.com>
To: 59469@debbugs.gnu.org
Subject: bug#59469: 29.0.50; Eshell "for" loop: Calling a non-lisp command (example: /usr/bin/tail) sets the variable exported in the {} block of "for var in list {}" to nil
Date: Mon, 21 Nov 2022 21:04:51 -0500	[thread overview]
Message-ID: <CAEc2VK05DZQipoBrHVqcVewuXiZbPRyCGJ1m2hvvwEeYksD=1A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2029 bytes --]

Hi,
I might be doing something wrong, but it appears that calling any non-lisp
command  (example: /usr/bin/tail) causes the variable set in the {} block
of "for var in list {}" to change to nil.

To duplicate, please create a file "bug.txt" in ~tmp,

   echo "line one" > ~/tmp/bug.txt

then run the following code -

In the code below, *please replace my full path
"/home/mzimmermann/tmp/bug.txt" with your full path. There seems to be an
unrelated issue trying to list ~/tmp/bug.txt*

  for file in (list "/home/mzimmermann/tmp/bug.txt") {
                  type-of $file
                  echo "file=$file";
                  # Create a variable. The back and forth between .log and
.txt is
                  # only there to simulate some useful work to set value of
samefile
                  export samefile="${echo
$file(:s/.txt/.log/)}"(:s/.log/.txt/);
                  echo "samefile=$samefile"
                  # Note that on my system, 'which tail' ==> /usr/bin/tail
                  tail $file
                  # Note that on my system, 'which cat' ==> eshell/cat is a
byte-compiled Lisp function in ‘em-unix.el’.
                  # cat $file
                  echo "samefile=$samefile"
                  echo "file=$file";
              }

Actual result:

================
string
file=/home/mzimmermann/tmp/bug.txt
samefile=/home/mzimmermann/tmp/bug.txt
line one
samefile=nil
file=/home/mzimmermann/tmp/bug.txt
================

Please *note how the contents of samefile is nullified. This is the bug I
am reporting here*

Expected result:
================
string
file=/home/mzimmermann/tmp/bug.txt
samefile=/home/mzimmermann/tmp/bug.txt
line one
samefile=/home/mzimmermann/tmp/bug.txt
file=/home/mzimmermann/tmp/bug.txt
================

Notes:

1. I tried this with other non-lisp functions (/usr/bin/gzip) and it caused
the same issue.

2. If we use "cat" which is an elisp function, the loop works as expected.

Thanks,
Milan Zimmermann

[-- Attachment #2: Type: text/html, Size: 2572 bytes --]

             reply	other threads:[~2022-11-22  2:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22  2:04 Milan Zimmermann [this message]
2022-11-22  2:50 ` bug#59469: Adding a simpler duplication of the issue Milan Zimmermann
2022-11-22  4:56   ` Jim Porter
2022-11-22  7:18     ` Milan Zimmermann
2023-01-25  1:39       ` Jim Porter
2023-01-29  6:55         ` bug#59469: 29.0.50; Eshell "for" loop: Calling a non-lisp command (example: /usr/bin/tail) sets the variable exported in the {} block of "for var in list {}" to nil (was: Adding a simpler duplication of the issue) Jim Porter
2023-02-10  5:44           ` Jim Porter

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAEc2VK05DZQipoBrHVqcVewuXiZbPRyCGJ1m2hvvwEeYksD=1A@mail.gmail.com' \
    --to=milan.zimmermann@gmail.com \
    --cc=59469@debbugs.gnu.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).