Home Explore Blog CI



man-pages

25th chunk of `less.man`
0ddfb7a120b2f9695ac768523cef7b9a783881e8ecd3cdfc0000000100000fba

       ?x     True if there is a next input file (that is, if the current input file is not the last one).

       Any  characters other than the special ones (question mark, colon, period, percent, and backslash) become literally part of the prompt.  Any of the special characters may be included in the prompt literally by preced‐
       ing it with a backslash.

       Some examples:

       ?f%f:Standard input.

       This prompt prints the filename, if known; otherwise the string "Standard input".

       ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:‐...

       This prompt would print the filename, if known.  The filename is followed by the line number, if known, otherwise the percent if known, otherwise the byte offset if known.  Otherwise, a dash is  printed.   Notice  how
       each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash.

       ?n?f%f .?m(%T %i of %m) ..?e(END) ?x‐ Next\: %x..%t";

       This  prints  the  filename if this is the first prompt in a file, followed by the "file N of N" message if there is more than one input file.  Then, if we are at end‐of‐file, the string "(END)" is printed followed by
       the name of the next file, if there is one.  Finally, any trailing spaces are truncated.  This is the default prompt.  For reference, here are the defaults for the other two prompts (-m and -M respectively).  Each  is
       broken into two lines here for readability only.

       ?n?f%f .?m(%T %i of %m) ..?e(END) ?x‐ Next\: %x.:
            ?pB%pB\%:byte %bB?s/%s...%t

       ?f%f .?n?m(%T %i of %m) ..?ltlines %lt‐%lb?L/%L. :
            byte %bB?s/%s. .?e(END) ?x‐ Next\: %x.:?pB%pB\%..%t

       And here is the default message produced by the = command:

       ?f%f .?m(%T %i of %m) .?ltlines %lt‐%lb?L/%L. .
            byte %bB?s/%s. ?e(END) :?pB%pB\%..%t

       The prompt expansion features are also used for another purpose: if an environment variable LESSEDIT is defined, it is used as the command to be executed when the v command is invoked.  The LESSEDIT string is expanded
       in the same way as the prompt strings.  The default value for LESSEDIT is:

            %E ?lm+%lm. %g

       Note that this expands to the editor name, followed by a + and the line number, followed by the shell‐escaped file name.  If your editor does not accept the "+linenumber" syntax, or has other differences in invocation
       syntax, the LESSEDIT variable can be changed to modify this default.

SECURITY
       When the environment variable LESSSECURE is set to 1, less runs in a "secure" mode.  This means these features are disabled:

              !      the shell command

              |      the pipe command

              :e     the examine command.

              v      the editing command

              s  -o  log files

              -k     use of lesskey files

              -t     use of tags files

                     metacharacters in filenames, such as *

                     filename completion (TAB, ^L)

       Less can also be compiled to be permanently in "secure" mode.

COMPATIBILITY WITH MORE
       If  the  environment  variable LESS_IS_MORE is set to 1, or if the program is invoked via a file link named "more", less behaves (mostly) in conformance with the POSIX "more" command specification.  In this mode, less
       behaves differently in these ways:

       The -e option works differently.  If the -e option is not set, less behaves as if the -e option were set.  If the -e option is set, less behaves as if the -E option were set.

       The -m option works differently.  If the -m option is not set, the medium prompt is used, and it is prefixed with the string "--More--".  If the -m option is set, the short prompt is used.

       The -n option acts like the -z option.  The normal behavior of the -n option is unavailable in this mode.

       The parameter to the -p option is taken to be a less command rather than a search pattern.

Title: Less: Prompt Examples, Editing, Security, and Compatibility
Summary
This section provides examples of complex prompt strings with conditional logic in `less`. It covers the default prompts for different modes (normal, -m, -M) and the default message for the '=' command. It also describes how the LESSEDIT environment variable is used to define the command invoked by the 'v' command, expanding it similarly to prompts with filename and line number. It also outlines the security features enabled when LESSSECURE is set to 1, disabling shell commands, editing, logging, lesskey files, tags files, and filename features. It also describes how `less` behaves in accordance with the POSIX "more" command specification, when `LESS_IS_MORE` is set to 1 or when invoked as `more`.