You are here: Appendix > Notes about using Luna shell (lunash)

Notes about using Luna shell (lunash)

 

Control Characters and Escape Sequences

The generic CLI software supports a variety of control characters and escape sequences for various control, command line recall and editing features. These are detailed in the tables below.

In the tables, control characters are in the form “Ctrl-C” where “C” identifies the control character (e.g. Control C or hexadecimal 0x03). Some literature uses the form “^C”. Hex, or hexadecimal values are designated with a leading “0x” as is customary in C/C++ code. The “Name” column indicates the standard ASCII abbreviation for the control character. The “Alternate Name” indicates commonly used names. In many cases, the “Alternate Name” corresponds to an identifier on the keyboard key. Note, however, that the “Delete” key is often mapped to an escape sequence, and not to the ASCII “DEL” character (hex 0x7F).

Handling of the following control characters is provided by standard Linux TTY terminal handling features:

Character

Hex

Name

Alternate Name

Function

Ctrl-C

0x03

ETX

 

Terminate Luna Shell

Ctrl-Q

0x11

DC1

X-On

Start output

Ctrl-S

0x13

DC3

X-Off

Stop output

Ctrl-U

0x15

NAK

 

Erase line

Ctrl-A

0x01

SOH

 

Move to start of line

Ctrl-B

0x02

STX

 

Move 1 character to left

Ctrl-D

0x04

EOT

 

Delete 1 character at cursor

Ctrl-E

0x05

ENQ

 

Move to end of line

Ctrl-F

0x06

ACK

 

Move 1 character to right

Ctrl-H

0x08

BS

Backspace

Delete 1 character to left

Ctrl-I

0x09

HT

Tab

Insert command completion

Ctrl-J

0x0A

LF

 

Linefeed Accept command line

Ctrl-K

0x0B

VT

 

Delete characters to end of line

Ctrl-L

0x0C

FF

 

Re-display line

Ctrl-M

0x0D

CR

Enter/Carriage Return

Accept command line

Ctrl-N

0x0E

SO

 

Retrieve next history entry

Ctrl-P

0x10

DLE

 

Retrieve previous history entry

Ctrl-R

0x12

DC2

 

Search history entries

Ctrl-T

0x14

DC4

 

Transpose 2 characters to left

Ctrl-V

0x16

SYN

 

Quote next character

Ctrl-W

0x17

ETB

 

Wipe to the mark

Ctrl-X

0x18

CAN

 

Exchange cursor position and mark

Ctrl-Y

0x19

EM

 

Yank

Ctrl-[

0x1B

ESC

Escape

Escape sequence with next characters

Ctrl-\

0x1C

FS

 

Terminate Luna Shell

Ctrl-]

0x1D

GS

 

Move to right to next character

Ctrl-?

0x7F

DEL

Delete

 Delete 1 character to left

 

Note: Alternate Names “Delete” and “Backspace” perform the same function: Delete 1 character to left.

Note: Control characters not listed here (Ctrl-@, Ctrl-G, Ctrl-O, Ctrl-Z, Ctrl-^, Ctrl-_) have no effect other than causing a Ctrl-G beep to be returned.

Note: Ctrl-D on an empty line terminates Luna Shell.

Note: Ctrl-V and Ctrl-] require one following character. Ctrl-[ (ESC) requires one or more following characters. Ctrl-R requires input. (Ctrl-V was disabled for Luna SA 3.0.1 for security and usability reasons. It allowed control characters to be embedded in parameters such as partition names.)

In the escape sequence table, the “Sequence” column indicates the character or characters that must follow the Escape character in order to perform the function indicated in the “Function” column. In some cases these are control characters (e.g. Ctrl-H). In some cases these are single characters in single quotes (e.g. ‘ ‘ for space). In some cases ranges are shown (e.g. 1 to 2147483647 to indicate a number range). In some cases a string is shown and spaces are inserted only for clarity (e.g. “[ A” to indicate a left square bracket followed by a capital A).

The “Key” column indicates the keyboard key that is commonly mapped to that escape sequence when VT-100 or ANSI terminal emulation is used.

The Editline library provides handling of the following escape sequences:

 

Sequence    Hex Key    Function   
Ctrl-H    0x08    Delete 1 word to left   
Ctrl-[    0x1B    List possible completions   
‘ ‘    0x20    Set the mark   
‘.’    0x2E    Insert last argument   
‘<’    0x3C    Retrieve first history entry   
‘>’    0x3E    Retrieve last history entry   
‘?’    0x3F    List possible completions   
‘b’     0x62    Move 1 word to left   
‘bd’     0x64    Delete 1 word to right   
‘f’     0x66    Move 1 word to right   
‘l’     0x6C    Lowercase 1 word to right
‘m’    0x6D    Toggle meta mode   
‘u’     0x75    Uppercase 1 word to right
‘w’    0x77    Copy region (to mark?)   
‘y’    0x79    Yank   
Ctrl-?    0x7F     Delete 1 word to left   
1 to 2147483647    0x31 to 0x32 …    Set repeat count for next command or character    
‘A’ to ‘Z’    0x41 to 0x5A    Insert environment variable “_A_” to “_Z_” value   
[ A    0x5B 0x41    Up Arrow Retrieve previous history entry    
[ B 0x5B 0x42 Down Arrow Retrieve next history entry    
[ C 0x5B 0x43 Right Arrow Move 1 character to right
[ D 0x5B 0x44 Left Arrow Move 1 character to left    
[ 1 0x5B 0x31 0x7E Home    Move to start of line    
[3 0x5B 0x33 0x7E Delete    Delete 1 character at cursor    
[4 0x5B 0x34 0x7E End    Move to end of line    
[5 0x5B 0x35 0x7E Page Up    Retrieve first history entry    
[6 0x5B 0x36 0x7E Page Down    Retrieve last history entry   

 

Note: Escape sequences shown starting with ‘[‘ may also start with ‘O’ (e.g. “[ A” = “O A”).    

Note: Escape sequences shown terminated with a ‘~’ may terminate with any character (e.g. “[ 1 ~” = “[ 1 ?”).

Note: Escape sequences not listed here (such as “[ 2 ~”, commonly produced by the Insert key) have no effect other than causing a Ctrl-G beep to be returned.

 

Command Line Recall and Editing

The recall (or history) functionality allows a user to retrieve the 100 most recently entered commands, optionally modify them and re-enter them.

The recall functionality does not record blank lines containing no information (i.e. those lines with the cursor adjacent to the prompt when <Enter> is pressed). The recall functionality does record lines with nothing but space characters and those starting with a “#” comment character.

The editing functionality allows editing a command line before it is submitted. The cursor may be moved and characters may be inserted or removed.

Commands are submitted for execution with a carriage return or linefeed character. The position of the cursor on the line is not important when a command is submitted for execution.

Command line recall and editing functionality depends on the use of control characters and escape sequences. Using appropriate keyboards and terminal emulation or SSH software, certain keys (such as Home, End, Up-Arrow, Down-Arrow etc.) may be mapped to appropriate control characters and escape sequences in order to conform to common conventions for command line recall and editing.

Case Insensitivity

Commands and options entered by the user should not be sensitive to case. If a user accidentally leaves the Caps-Lock key on, or by habit capitalizes some commands or options, they should not have to re-enter or edit the command line.

Command parameters, however, are passed to command executables with the same case as entered on the command line. Command executables must deal with case issues as appropriate for the command.

Quoting

Some command parameters require quoting with double quotes. This is generally necessary only in cases where parameters must support embedded spaces. For example, the command “network hostname “my host”” could be useful to name a host “my host”. The “network hostname” command does not support the use of embedded spaces for the <hostname> parameter.

Aliases

Some command and option names support aliases. For example, the “?” command is an alias for the “help” command. Thus, users can run the help command using either “help” or “?”.

The command-line interface does not allow the discovery of aliases via “help”. For example, the command “help ?” displays help text for the “help” command (the preferred name) rather than the “?” command (an alias).

Aliases are discoverable via command completion functionality however, either by completion or by listing the possible completions for a command, sub-command or option.

Short Forms

All commands and options support non-ambiguous short forms. The generic CLI software handles this for all commands, sub-commands and options that are defined.

For example, if no other commands exist which start with “h”, the commands “help”, “hel”, “he” and “h” will all invoke the “help” command.

If a short form of a command is attempted, and the command is ambiguous, an error message is displayed.

 

Dashes

For those familiar with previous releases of Luna appliance products, where some latitude was permitted in the syntax, especially with respect to dashes in front of subcommands and options, this has changed. As the Luna products continue to gain capability and flexibility, the numbers of commands continue to increase, and it has become necessary to tighten the operation.

The lunash command-line is now strict with regard to syntax. If a command parameter calls for a leading dash, then the command-line shell rejects a command where that dash is missing. If a command fails to work, place a question mark in front of it to see a syntax summary for that command, before looking for other reasons that it might not have performed as expected. Note, no space is permitted between a command parameter and its leading dash.