ghantoos / lshell

lshell is a shell coded in Python, that lets you restrict a user's environment to limited sets of commands, choose to enable/disable any command over SSH (e.g. SCP, SFTP, rsync, etc.), log user's commands, implement timing restriction, and more.
GNU General Public License v3.0
435 stars 112 forks source link

[PATCH]: Adding support for newline escape character “\” to support long commands + PS2 prompts #131

Open kamade opened 8 years ago

kamade commented 8 years ago

Lshell does not have any support for bash-like PS2 prompts when inputting commands that span multiple lines:

You are in a limited shell. Type '?' or 'help' to get the list of allowed commands :~$ ls \ images license.lic

the “\” is ignored, ls immediately returns.

The patch adds support for recognizing a bash-like line continuation ('\') character and providing a PS2 prompt for further input. After the line continuations end, the patch appends all those segments into one command(and strips the '\' characters) before sending it to cmdparse(). This way the rest of lshell remains agnostic to the presence of line continuations and receives 1 contiguous cmd.

The attached patch has been applied in our code base and is being shared Upstream

lshell-newline-escape-character-support.patch.txt