Less not using lesspipe

My less does not respect the lessopen environment variable.

The less version is:

less 668 (PCRE2 regular expressions)
Copyright (C) 1984-2024  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less
$ which less
/run/current-system/sw/bin/less
$ ls -l `which less`
/run/current-system/sw/bin/less -> /nix/store/z387y1yyhx7p41q1jr2bz3yzcdna36d9-less-668/bin/less

The LESS-related env variables are:

$ env | grep -i less
LESSOPEN=|/nix/store/75fsi0w4qjxc97ggznrc67mr3d88xhjn-lesspipe-2.11/bin/lesspipe.sh %s
PAGER=less
LESSKEYIN_SYSTEM=/nix/store/3jyyi36yacqxkhrzk5ynkwc6nkw2jsq3-lessconfig

$ cat $LESSKEYIN_SYSTEM
#command



#line-edit


#env
LESS=-R

I don’t know why it is not working…

This LESS behaves quite like in secure mode, which features disabled v(edit) and :e commands.

But as far as I see the default less comes with no secure, as in

withSecure ? false,

I don’t know what’s happening, can somebody help?

I’ve investigated a bit further, the less IS build with (“configureFlags”,“–sysconfdir=/etc --with-regex=pcre2 --without-secure”), I don’t know exactly what --without-secure mean.

Sounds like this is the issue fixed in #352298. The fix was moved to staging due to some mass rebuilds and looks like is currently on its way to nixos-unstable.

2 Likes

That’s kinda weird, since I’m on nixpkgs-master and is already using less with this patch. Weirdly the patches section in the .drv file is empty.

In fact, it made its way into unstable, however, it is reverted… It’s reapplied in master though

What’s not working? What’s the behavior you see, and what do you expect instead?

Also, master isn’t meant to be used directly, it’s basically the same as using nixos-unstable but you have to waste time building everything yourself.

I think I’ve stated the problem clearly enough.

The problem I find is that less is not using lesspipe, which made me investigate the problem and come to the conclusion that less is always in secure mode even without LESSSECURE value set.

The master thing is because I want to use some broken software(quite urgently) on unstable and the master branch fixed it, and I forgot to change it back. I may change this in the future.

As far as I see, master have most packages built, but sometimes large packages is not updated, e.g. libreoffice.

And again, how are you determining this? What is the behavior you see vs what you expect? What exact command are you running to test this?

I don’t know how lessopen works exactly, but:

  1. when I open up a image file(tested with .jpg, .png, .bmp) with strace less filename, the trace showed nothing about the lesspipe.sh part. It should run lesspipe.sh as a preprocessor and give me the metadata about the image, instead of asking me if I want to display a binary file.
  2. I tried running lesspipe.sh directly on those images with lesspipe.sh $filename, and it gave me the desired output of using exiftool to capture the data from the image.
  3. when I run less on text files with less filename and tried functionalities disabled by secure mode, it bells and tell me that the command isn’t available.

I hope these additional information can be helpful.