* I can't explain the following
@ 2022-04-26 15:49 Jim
2022-04-27 1:22 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Jim @ 2022-04-26 15:49 UTC (permalink / raw)
To: zsh
[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]
Hi everyone,
While working on my .zshenv file I discovered something strange that I
can't explain.
The changes(still a work in progress) had a glob that took some time to
complete
and won't be there when I finish. This made it quite noticeable. Everything
I was
doing in a zsh instance seemed to work normally with one notable exception,
that
I know of.
% less $file # executes .zshenv before outputting content of file
If .zshrc has some "test" print statement(s), they are outputs and
not the file??
% < $file outputs file and pipes it through less ? I should remember
why, anyway!
% cat $file outputs content of file as expected
% more $file outputs content of file as expected
What I can't figure out is why zsh/"less" does what it does. Could someone
enlighten me?
Is there a way of "tracing" what is happening?
BTW "less" is not an alias or function.
Distribution: Devuan
ZSH_VERSION 5.8
ZSH_PATCHLEVEL debian/5.8-6+deb11u1
LESS='-R -M --shift 5'
LESSOPEN='|lesspipe %s'
Thanks in advance for any help you can provide.
Jim Murphy
[-- Attachment #2: Type: text/html, Size: 1510 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't explain the following
2022-04-26 15:49 I can't explain the following Jim
@ 2022-04-27 1:22 ` Bart Schaefer
2022-04-27 15:20 ` Jim
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2022-04-27 1:22 UTC (permalink / raw)
To: linuxtechguy; +Cc: zsh
On Tue, Apr 26, 2022 at 8:51 AM Jim <linux.tech.guy@gmail.com> wrote:
>
> What I can't figure out is why zsh/"less" does what it does. Could someone enlighten me?
It's this:
> LESSOPEN='|lesspipe %s'
> Is there a way of "tracing" what is happening?
strace -ff -o tracefile less ...
... and then look through the set of files that are produced. To save
you the trouble:
execve("/bin/sh", ["sh", "-c", "/bin/zsh -c lesspipe\\ C.gz"],
0x7ffc15c0b800 /* 56 vars */) = 0
Now, why it's running lesspipe with "/bin/zsh -c" instead of with
/bin/sh or at least "/bin/zsh -fc" I don't know. The doc for "less"
doesn't mention using $SHELL for this case.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't explain the following
2022-04-27 1:22 ` Bart Schaefer
@ 2022-04-27 15:20 ` Jim
2022-04-27 15:59 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Jim @ 2022-04-27 15:20 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
If I wasn't testing things in .zshenv, I wouldn't have known anything
about this. Another reason to watch what goes into startup files,
especially .zshenv.
Feels like I'm watching "Catch 22".
On Tue, Apr 26, 2022 at 8:22 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:
> Now, why it's running lesspipe with "/bin/zsh -c" instead of with
> /bin/sh or at least "/bin/zsh -fc" I don't know. The doc for "less"
> doesn't mention using $SHELL for this case.
>
I wonder if the folks maintaining less would even consider this an issue?
Oh well.
At least I know what is going on, and what I shouldn't do in .zshenv since
I doubt I
will stop using less. Makes me wonder if less is the only command that does
something like this.
Thanks for the info. Learned my something new for the day.
Jim Murphy
[-- Attachment #2: Type: text/html, Size: 1349 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: I can't explain the following
2022-04-27 15:20 ` Jim
@ 2022-04-27 15:59 ` Bart Schaefer
2022-04-27 17:47 ` Jim
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2022-04-27 15:59 UTC (permalink / raw)
To: linuxtechguy; +Cc: zsh
On Wed, Apr 27, 2022 at 8:22 AM Jim <linux.tech.guy@gmail.com> wrote:
>
>> Now, why it's running lesspipe with "/bin/zsh -c" instead of with
>> /bin/sh or at least "/bin/zsh -fc" I don't know.
>
> I wonder if the folks maintaining less would even consider this an issue?
That execve() is pretty obviously coming from system(). Try writing a
little C program that calls system() and strace that, maybe the
library is supplying the "/bin/zsh -c" part because lesspipe is a
script (which is also undocumented and potentially wrong, since the
script does have a #! line).
> At least I know what is going on, and what I shouldn't do in .zshenv since I doubt I
> will stop using less.
You could stop setting LESSOPEN. I long ago decided the "convenience"
of having gzip files etc. automatically unpacked was not worth the
other side-effects.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-27 17:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 15:49 I can't explain the following Jim
2022-04-27 1:22 ` Bart Schaefer
2022-04-27 15:20 ` Jim
2022-04-27 15:59 ` Bart Schaefer
2022-04-27 17:47 ` Jim
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).