4

I can not come up with an example of how I could/would use lessecho. The description in the man page is fairly straight forward but is not helping me come up with a use case:

DESCRIPTION

lessecho is a program that simply echos its arguments on standard output. But any metacharacter in the output is preceded by an "escape" character, which by default is a backslash.

I searched through shellscripts on github and could not find any use of the command. Can you give one or two (or three) examples of lessecho? The more varied the use case the better.

  • 1
    Look into the source code of less itself. The lglob function in filename.c calls lessopen. It's a helper program to solve a specific problem in implementing less, not really meant to be used elsewhere. – Wumpus Q. Wumbley Sep 14 '14 at 0:16
4

This is a companion program for less. It is used internally in some configurations (determined at compile time) to call a shell from commands where you can specify a wildcard pattern that stands for a list of file names: the “examine” (:e) command and a few others (-o, -O, -T). The weird quoting is something that less parses internally. The point of using lessecho instead of echo is to make spaces in file names distinguishable from spaces used to separate file names. The command printf '%s\000' would serve the same purpose, with less parsing effort, but isn't available on some of the ancient unices that less still works on.

I don't know why less uses this approach on modern unix systems instead of calling the glob library function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.