From cc49042294aceb3ab30396eb5731e4ac0cf601bc Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 20 Aug 2014 22:01:24 -0700 Subject: Parse slices even for empty variables When a variable is parsed as being empty, parse out the slice and validate the indexes anyway, behaving for slicing purposes as if the variable had a single empty value. Besides providing errors when expected, this also fixes the following: set -l foo echo "$foo[1]" This used to print "[1]", now it properly prints nothing. --- tests/expansion.err | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/expansion.err') diff --git a/tests/expansion.err b/tests/expansion.err index e69de29b..6346f23f 100644 --- a/tests/expansion.err +++ b/tests/expansion.err @@ -0,0 +1,18 @@ +Array index out of bounds +fish: show "$foo[2]" + ^ +Array index out of bounds +fish: show $foo[2] + ^ +Array index out of bounds +fish: show "$foo[1 2]" + ^ +Array index out of bounds +fish: show $foo[1 2] + ^ +Array index out of bounds +fish: show "$foo[2 1]" + ^ +Array index out of bounds +fish: show $foo[2 1] + ^ -- cgit v1.2.3