zsh-users
 help / color / mirror / Atom feed
* Bug? piping ls to anonymous function changes subsequent behaviour of ls
       [not found] <1846474183.1100394.1601253063804.ref@mail.yahoo.com>
@ 2020-09-28  0:31 ` vapnik spaknik
  2020-09-28  0:40   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: vapnik spaknik @ 2020-09-28  0:31 UTC (permalink / raw)
  To: Zsh Users

After piping ls to an anonymous function it stops working (i.e. produces no output) on subsequent invocations.
I have to start another shell to get it working again:

> ls
Desktop Downloads Videos... etc.
> ls | () {echo foo}
foo
> ls

> # try again..
> ls

> #!?*#!!! try in a new shell...
> zsh
....
> ls
Desktop Downloads Videos... etc.
> # Yay! working again

What's going on? Is this a bug?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug? piping ls to anonymous function changes subsequent behaviour of ls
  2020-09-28  0:31 ` Bug? piping ls to anonymous function changes subsequent behaviour of ls vapnik spaknik
@ 2020-09-28  0:40   ` Bart Schaefer
  2020-09-28  1:02     ` vapnik spaknik
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2020-09-28  0:40 UTC (permalink / raw)
  To: vapnik spaknik; +Cc: Zsh Users

On Sun, Sep 27, 2020 at 5:31 PM vapnik spaknik <vapniks@yahoo.com> wrote:
>
> After piping ls to an anonymous function it stops working (i.e. produces no output) on subsequent invocations.

Not reproducible for me with "zsh -f".

Have you tried running "whence -a ls" to find out if or to what it has
been redefined?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug? piping ls to anonymous function changes subsequent behaviour of ls
  2020-09-28  0:40   ` Bart Schaefer
@ 2020-09-28  1:02     ` vapnik spaknik
  2020-09-28  2:36       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: vapnik spaknik @ 2020-09-28  1:02 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

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

 

On Monday, September 28, 2020, 01:41:10 AM GMT+1, Bart Schaefer <schaefer@brasslantern.com> wrote:

>Not reproducible for me with "zsh -f".

>Have you tried running "whence -a ls" to find out if or to what it has
>been redefined?

Yep, it was aliased, but that isn't the problem. I've found that the anonymous function is being assigned to the left hand side of the pipe, but only the first time that pipeline is run in a new shell. Very strange.

From a new shell:
> which -a ls 
ls: aliased to ls --color=auto
/bin/ls
> /bin/ls | () {echo foo}
foo
> /bin/ls
foo
> which /bin/ls
/bin/ls () {
 echo foo
}
> unfunction /bin/ls
> /bin/ls
Downloads Documents etc...
> # Yay! now try again in the same shell:
> /bin/ls | () {echo foo}
foo
> /bin/ls
Downloads Documents etc...
> # back to normal behaviour!

If I start a new shell the same thing happens again, i.e. the first time I pipe to the anonymous function it is actually assigned to the left hand side, but subsequently it isn't.
  

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug? piping ls to anonymous function changes subsequent behaviour of ls
  2020-09-28  1:02     ` vapnik spaknik
@ 2020-09-28  2:36       ` Bart Schaefer
  2020-09-29 19:06         ` vapnik spaknik
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2020-09-28  2:36 UTC (permalink / raw)
  To: vapnik spaknik; +Cc: Zsh Users

On Sun, Sep 27, 2020 at 6:02 PM vapnik spaknik <vapniks@yahoo.com> wrote:
>
> From a new shell:
> > which -a ls
> ls: aliased to ls --color=auto
> /bin/ls
> > /bin/ls | () {echo foo}
> foo
> > /bin/ls
> foo
> > which /bin/ls
> /bin/ls () {
> echo foo
> }

Something else funny is happening here.  This is defining /bin/ls as a
function with body "echo foo", as if the "|" were not present in the
command at all.

Try using "set -x" (or "setopt xtrace" if you prefer) before the first
attempt to pipe.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug? piping ls to anonymous function changes subsequent behaviour of ls
  2020-09-28  2:36       ` Bart Schaefer
@ 2020-09-29 19:06         ` vapnik spaknik
  0 siblings, 0 replies; 5+ messages in thread
From: vapnik spaknik @ 2020-09-29 19:06 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

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

 

On Monday, September 28, 2020, 03:36:17 AM GMT+1, Bart Schaefer <schaefer@brasslantern.com> wrote:

>Something else funny is happening here.  This is defining /bin/ls as a
>function with body "echo foo", as if the "|" were not present in the
>command at all.
>
>Try using "set -x" (or "setopt xtrace" if you prefer) before the first
>attempt to pipe.

After spending some time fiddling with my ~/.zshrc config file I found the culprit:

eval "$(fasd --init zsh-hook)"

I've submitted a bug report to the fasd repo: https://github.com/clvv/fasd/issues/156  

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-29 19:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1846474183.1100394.1601253063804.ref@mail.yahoo.com>
2020-09-28  0:31 ` Bug? piping ls to anonymous function changes subsequent behaviour of ls vapnik spaknik
2020-09-28  0:40   ` Bart Schaefer
2020-09-28  1:02     ` vapnik spaknik
2020-09-28  2:36       ` Bart Schaefer
2020-09-29 19:06         ` vapnik spaknik

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ http://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git