help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get eshell to do what I used to do with shell


From: Joel Reicher
Subject: Re: How to get eshell to do what I used to do with shell
Date: Sun, 11 Aug 2024 21:27:34 +1000
User-agent: Gnus/5.13 (Gnus v5.13)

"KARR, DAVID" <dk068x@att.com> writes:

Section 1.1 mentions an obscure way of filtering ls output, using an example like “ls -lt **/*.doc(Lk+100aM+6)”. I couldn’t get any variation of that to work. It’s not clear whether it’s saying that is eshell functionality, or something about the most common implementations of “ls”.

Why do you think ls is doing anything interesting there?

When I do something simple like this: “ls -l | grep "txt" | sort”, all the output lines are prefixed with “(standard input):”. I haven’t searched through the info manual yet, but I asked github copilot about this, and it said that “eshell/grep” instead of “grep” would fix that, but that didn’t work either (I don’t expect everything from copilot to be 100% accurate).

Keep in mind that when you execute a command line in eshell, you're executing some lisp, because eshell is written in lisp.

Depending on your configuration, the behaviour might be to execute a lisp function (if there is one), and that's probably the case with grep. If eshell fails to find a lisp function matching the command's name, it will then attempt to find an external program by that name.

Also - and this is very important - that pipe is implemented in lisp.

Both of these things can be overridden on demand by using the '*' character. For example you can force grep to call the external program by running

*grep

instead.

Compare the output of

grep blah foo

and

*grep blah foo

(the difference is much clearer if you do not use pipe to begin with)

For pipes, you can do

grep blah foo *| grep something

and this will force the use of an external shell implementation of pipe which, as far as I know, implicitly forces an external program to be used for both commands too. There may be situations you want the in-lisp pipe (such as piping to a lisp function instead of an external program).

You may also find this useful.

https://www.masteringemacs.org/article/complete-guide-mastering-eshell

Cheers,

       - Joel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]