mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
Base: Add manpage entry for history events
This commit is contained in:
parent
c1b4e86004
commit
ddd0c1dd8b
1 changed files with 38 additions and 1 deletions
|
@ -28,6 +28,10 @@ String of characters that are not _Special_ or _Syntactic Elements_
|
||||||
##### Glob
|
##### Glob
|
||||||
String of characters containing at least one of `*?` in _bareword_ position
|
String of characters containing at least one of `*?` in _bareword_ position
|
||||||
|
|
||||||
|
##### History Events
|
||||||
|
A _designator_ starting with `!` in _bareword_ position that describes a word or a range of words from a previously entered command.
|
||||||
|
Please look at the section named 'History Event Designators' for a more thorough explanation. Only allowed in interactive mode.
|
||||||
|
|
||||||
##### Single Quoted String
|
##### Single Quoted String
|
||||||
Any sequence of characters between two single quotes (`'`)
|
Any sequence of characters between two single quotes (`'`)
|
||||||
|
|
||||||
|
@ -36,6 +40,7 @@ Any sequence of _Double Quoted String Part_ tokens:
|
||||||
* Barewords
|
* Barewords
|
||||||
* Single Quotes
|
* Single Quotes
|
||||||
* Variable References
|
* Variable References
|
||||||
|
* History Events
|
||||||
* Evaluate expressions
|
* Evaluate expressions
|
||||||
* Escaped sequences
|
* Escaped sequences
|
||||||
|
|
||||||
|
@ -309,6 +314,25 @@ match "$(make_some_value)" {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### History Event Designators
|
||||||
|
History expansion may be utilised to reuse previously typed words or commands.
|
||||||
|
Such expressions are of the general form `!<event_designator>(:<word_designator>)`, where `event_designator` would select an entry in the shell history, and `word_designator` would select a word (or a range of words) from that entry.
|
||||||
|
|
||||||
|
| Event designator | effect |
|
||||||
|
| :- | :----- |
|
||||||
|
| `!` | Select the immediately preceding command |
|
||||||
|
| _n_ | Select the _n_'th entry in the history |
|
||||||
|
| -_n_ | Select the last _n_'th entry in the history |
|
||||||
|
| _str_ | Select the most recent entry starting with _str_ |
|
||||||
|
| ?_str_ | Select the most recent entry containing _str_ |
|
||||||
|
|
||||||
|
| Word designator | effect |
|
||||||
|
| :-- | :----- |
|
||||||
|
| _n_ | The _n_'th word, starting with 0 as the command |
|
||||||
|
| `^` | The first word (index 0) |
|
||||||
|
| `$` | The last word |
|
||||||
|
| _x_-_y_ | The range of words starting at _x_ and ending at _y_ (inclusive) |
|
||||||
|
|
||||||
## Formal Grammar
|
## Formal Grammar
|
||||||
|
|
||||||
### Shell Grammar
|
### Shell Grammar
|
||||||
|
@ -382,6 +406,7 @@ list_expression :: ' '* expression (' '+ list_expression)?
|
||||||
expression :: evaluate expression?
|
expression :: evaluate expression?
|
||||||
| string_composite expression?
|
| string_composite expression?
|
||||||
| comment expression?
|
| comment expression?
|
||||||
|
| history_designator expression?
|
||||||
| '(' list_expression ')' expression?
|
| '(' list_expression ')' expression?
|
||||||
|
|
||||||
evaluate :: '$' '(' pipe_sequence ')'
|
evaluate :: '$' '(' pipe_sequence ')'
|
||||||
|
@ -391,7 +416,7 @@ string_composite :: string string_composite?
|
||||||
| variable string_composite?
|
| variable string_composite?
|
||||||
| bareword string_composite?
|
| bareword string_composite?
|
||||||
| glob string_composite?
|
| glob string_composite?
|
||||||
| brace string_composite?
|
| brace_expansion string_composite?
|
||||||
|
|
||||||
string :: '"' dquoted_string_inner '"'
|
string :: '"' dquoted_string_inner '"'
|
||||||
| "'" [^']* "'"
|
| "'" [^']* "'"
|
||||||
|
@ -411,6 +436,18 @@ variable :: '$' identifier
|
||||||
|
|
||||||
comment :: '#' [^\n]*
|
comment :: '#' [^\n]*
|
||||||
|
|
||||||
|
history_designator :: '!' event_selector (':' word_selector_composite)?
|
||||||
|
|
||||||
|
event_selector :: '!' {== '-0'}
|
||||||
|
| '?' bareword '?'
|
||||||
|
| bareword {number: index, otherwise: lookup}
|
||||||
|
|
||||||
|
word_selector_composite :: word_selector ('-' word_selector)?
|
||||||
|
|
||||||
|
word_selector :: number
|
||||||
|
| '^' {== 0}
|
||||||
|
| '$' {== end}
|
||||||
|
|
||||||
bareword :: [^"'*$&#|()[\]{} ?;<>] bareword?
|
bareword :: [^"'*$&#|()[\]{} ?;<>] bareword?
|
||||||
| '\' [^"'*$&#|()[\]{} ?;<>] bareword?
|
| '\' [^"'*$&#|()[\]{} ?;<>] bareword?
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue