mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Shell: Add support for indexing into variables
Now a variable may have an optional slice (only _one_ slice), which can also use negative indices to index from the end. This works on both lists and strings. The contents of the slice have the same semantics as brace expansions. For example: ```sh $ x=(1 2 3 4 5 6) $ echo $x[1..3] # select indices 1, 2, 3 2 3 4 $ echo $x[3,4,1,0] # select indices 3, 4, 1, 0 (in that order) 4 5 2 1 $ x="Well Hello Friends!" $ echo $x[5..9] Hello ```
This commit is contained in:
parent
ddcef0452a
commit
3b8fa5a753
11 changed files with 391 additions and 56 deletions
|
@ -1885,6 +1885,7 @@ void Shell::possibly_print_error() const
|
|||
case ShellError::EvaluatedSyntaxError:
|
||||
warnln("Shell Syntax Error: {}", m_error_description);
|
||||
break;
|
||||
case ShellError::InvalidSliceContentsError:
|
||||
case ShellError::InvalidGlobError:
|
||||
case ShellError::NonExhaustiveMatchRules:
|
||||
warnln("Shell: {}", m_error_description);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue