Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem with 'ls | less' shell function



On Mon, Oct 17, 2022 at 04:50:20PM +0200, Mikael Magnusson wrote:
> On 10/17/22, Thomas Klausner <wiz@xxxxxxxxxxx> wrote:
> > Hi!
> >
> > I recently noticed a problem in zsh 5.9 (as built from pkgsrc) on
> > NetBSD 9.99.100. Since I didn't notice it before it could be related
> > to a change in NetBSD (I'm following the latest version), but I've
> > been told that the issue can be reproduced on Ubuntu 19.04 and FreeBSD
> > 13.1 too; but not in zsh 5.8.1, nor in most other shells though.
> >
> > The discussion on the NetBSD mailing list can be read in this thread:
> > https://mail-index.netbsd.org/current-users/2022/10/12/msg043076.html
> > but I'll summarize the issue I see in zsh here.
> >
> > I have a shell function I've been using for ages:
> >
> > dir() { ls -al "$@" | less; }
> >
> > Recently, when I tried suspending this with CTRL-Z and then resuming
> > it with 'fg', I get:
> >
> > $ dir
> > (CTRL-Z)
> > zsh: done       ls -al "$@" |
> > zsh: suspended
> > $ fg
> > [1]  + done       ls -al "$@" |
> >        continued
> > zsh: done                    ls -al "$@" |
> > zsh: suspended (tty output)
> > zsh: done                    ls -al "$@" |
> > zsh: suspended (tty output)
> >
> > The same thing works in NetBSD's ksh:
> >
> > $ fg
> > ls -al "$@" | less
> > (CTRL-Z)
> > [1] + Done                 ls -al "$@" |
> >       Stopped              less
> >
> > or in bash
> >
> > $ fg
> > ls -al "$@" | less
> > (CTRL-Z)
> >
> > [1]+  Stopped                 ls -al "$@" | less
> >
> > If I use '/bin/ls' in the shell function instead of 'ls', it works
> > fine.
> >
> > Any ideas what the issue could be?
> 
> The last bit implies that 'ls' is an alias or function, can you check
> the output of 'which ls'?

No, it isn't:

$ which ls
/bin/ls
$ type ls
ls is /bin/ls

Compare to

$ type ll
ll is an alias for ls -al
$ type dir
dir is a shell function from /home/wiz/.zshrc

But I take back the statement that it works with /bin/ls in the dir
function definition, it shows the same broken behaviour. Not sure why
I thought it worked before, sorry for that red herring.
 Thomas




Messages sorted by: Reverse Date, Date, Thread, Author