fish-shell/fish-shell — pull request #1110 by maxfl (2013-11-12 02:02:59+00:00)
Title: Implement not bound checked ranges $var[..n] and $var[n..]

This pull request is a demonstrator of a functionality requested by @GlitchMr in #826.

It implements a possibility to call slicing without bound checking. It is done by passing single bound ranges:
1) n..
2) ..n
3) As a consequence $var[..] is expanded as $var.

Currently only positive indexes are supported.

The usage is the following:
```sh
function atest
echo Two first: $argv[..2] , others: $argv[3..]
end
for i in ( seq 1 5 )
atest (seq $i)
end
```

Adding this functionality produces several questions which I do not know what to answer currently:
1) Is more reach functionality needed. I mean being safe to call any range inside a variable?
2) How to treat the direction? Currently the direction is determined based on left/right difference. In case of not checked bounds it will lead to the situation when $var[4..-4] will be expanded promptly or reversely depending on the var size. The possible options is to allow only positive direction and return empty list in this case.
3) It is possible to add modifiers to the slicing. For example: $var[3] and $var[--silent 3]: first one should issue error if the length of the variable is less than 3, another one should not. Does anybody need such a functionality? Any other syntax solutions?

Thank you for the feedback.