Skip to content

Commit

Permalink
Add # command.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Jan 31, 2023
1 parent f198ed3 commit e97ccd3
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* Add LESSUTFCHARDEF environment variable (github #275).

* Add # command (github #330).

* Add --wordwrap option (github #113).

* Add --no-vbell option (github #304).
Expand Down
1 change: 1 addition & 0 deletions cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define A_B_MOUSE 67
/* Note "X116" refers to extended (1006) X11 mouse reporting. */
#define A_X116MOUSE_IN 68
#define A_PSHELL 69
#define A_CLR_SEARCH 70

/* These values must not conflict with any A_* or EC_* value. */
Expand Down
8 changes: 7 additions & 1 deletion command.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ static void exec_mca(void)
else
lsystem(shellcmd, "!done");
break;
case A_PSHELL:
if (secure)
break;
lsystem(pr_expand(cbuf), "#done");
break;
#endif
#if PIPEC
case A_PIPE:
Expand Down Expand Up @@ -1890,13 +1895,14 @@ public void commands(void)
goto again;

case A_SHELL:
case A_PSHELL:
/*
* Shell escape.
*/
#if SHELL_ESCAPE
if (!secure)
{
start_mca(A_SHELL, "!", ml_shell, 0);
start_mca(action, (action == A_SHELL) ? "!" : "#", ml_shell, 0);
c = getcc();
goto again;
}
Expand Down
1 change: 1 addition & 0 deletions decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static unsigned char cmdtable[] =
'|',0, A_PIPE,
'v',0, A_VISUAL,
'!',0, A_SHELL,
'#',0, A_PSHELL,
'+',0, A_FIRSTCMD,

'H',0, A_HELP,
Expand Down
1 change: 1 addition & 0 deletions less.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
+_c_m_d Execute the less cmd each time a new file is examined.

!_c_o_m_m_a_n_d Execute the shell command with $SHELL.
#_c_o_m_m_a_n_d Execute the shell command, expanded like a prompt.
|XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command.
s _f_i_l_e Save input to a file.
v Edit the current file with $VISUAL or $EDITOR.
Expand Down
6 changes: 6 additions & 0 deletions less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ A pound sign (#) is replaced by the name of the previously examined file.
On Unix systems, the shell is taken from the environment variable SHELL,
or defaults to "sh".
On MS-DOS and OS/2 systems, the shell is the normal command processor.
.IP "# shell-command"
Similar to the "!" command,
except that the command is expanded in the same way as prompt strings.
For example, the name of the current file would be given as "%f".
.IP "| <m> shell-command"
<m> represents any mark letter.
Pipes a section of the input file to the given shell command.
Expand Down Expand Up @@ -2008,6 +2012,8 @@ This means these features are disabled:
.RS
.IP "!"
the shell command
.IP "#"
the pshell command
.IP "|"
the pipe command
.IP ":e"
Expand Down
1 change: 1 addition & 0 deletions lesskey.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ s toggle-option o
| pipe
v visual
! shell
# pshell
+ firstcmd
H help
h help
Expand Down
1 change: 1 addition & 0 deletions lesskey_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static struct lesskey_cmdname cmdnames[] =
{ "set-mark", A_SETMARK },
{ "set-mark-bottom", A_SETMARKBOT },
{ "shell", A_SHELL },
{ "pshell", A_PSHELL },
{ "status", A_STAT },
{ "toggle-flag", A_OPT_TOGGLE },
{ "toggle-option", A_OPT_TOGGLE },
Expand Down

0 comments on commit e97ccd3

Please sign in to comment.