GNU bug report logs - #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

Previous Next

Package: emacs;

Reported by: Milan Zimmermann <milan.zimmermann <at> gmail.com>

Date: Tue, 22 Nov 2022 02:06:02 UTC

Severity: normal

Found in version 29.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#59469: closed (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: Fri, 10 Feb 2023 05:45:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 9 Feb 2023 21:44:15 -0800
with message-id <fb8f8c86-fd74-d53b-2d5a-fba94b6dae4c <at> gmail.com>
and subject line Re: 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)
has caused the debbugs.gnu.org bug report #59469,
regarding 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
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
59469: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59469
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Milan Zimmermann <milan.zimmermann <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 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
[Message part 3 (text/plain, inline)]
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
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: Milan Zimmermann <milan.zimmermann <at> gmail.com>
Cc: 59469-done <at> debbugs.gnu.org
Subject: Re: 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)
Date: Thu, 9 Feb 2023 21:44:15 -0800
On 1/28/2023 10:55 PM, Jim Porter wrote:
> Here's an updated patch with an improved comment introducing Eshell's 
> iterative evaluation. Hopefully the added detail will help anyone else 
> who looks into this code (assuming I haven't replaced it with threads or 
> generator.el's CPS machinery by then, of course!).

Merged as c53255f677. Closing this bug now.


This bug report was last modified 2 years and 197 days ago.

Previous Next


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