mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 13:19:47 +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:
committed by
Andreas Kling
parent
ddcef0452a
commit
3b8fa5a753
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user