Commit Graph

15 Commits

Author SHA1 Message Date
David Adam
d0735882a3 add tests for the not-quite-fixed #5812 2019-04-18 21:12:25 +08:00
Aaron Gyes
014ab7935e Test expansion syntax errors.
If there is a better way to do stuff that will stop execution than
fish -c for our tests, please let me know.
2019-04-11 21:59:23 -07:00
Aaron Gyes
5615351f27 Revert "Update tests"
This reverts commit 36367e4882.
2018-11-28 06:27:21 -08:00
Aaron Gyes
36367e4882 Update tests
Fish is always executed as ../test/root/bin/fish in these expect tests
2018-11-27 11:59:44 -08:00
ridiculousfish
d6a5792ce2 Allow nested square brackets again
Code like echo $list[$var[1]] was producing an error because of
nested square brackets. Allow these brackets again.

Fixes #5362
2018-11-22 17:57:27 -08:00
ridiculousfish
f4d666f56c Allow user to set and unset path property of variables
This adds flags --path and --unpath to builtin set, analogous to
--export and --unexport. These flags change whether a variable is
marked as a path variable.

Universal variables cannot yet be path variables.
2018-10-19 17:39:21 -07:00
ridiculousfish
5947aa0171 Join variables by their delimiter in quoted expansion
This switches quoted expansion like "$foo" to use foo's delimiter instead of
space. The delimiter is space for normal variables and colonf or path variables.
Expansions like "$PATH" will now expand using ':'.
2018-10-19 17:35:36 -07:00
ridiculousfish
d73c487d60 Restore %self to refer to the fish pid
This brings back the %self argument. Like the original %self it only expands
if the argument is literally %self.
2018-10-19 16:17:25 -07:00
Kurtis Rader
864dbaeb43 use new logmsg and set --show in tests 2017-08-03 21:37:02 -07:00
Fabian Homborg
44f2f37bd4 Remove "Array index out of bounds" errors
This just removes every invalid index.

That means with `set foo a b c` and the "show" function from tests/expand.in:

- `show $foo[-5..-1]` prints "3 a b c"
- `show $foo[-10..1]` prints "1 a"
- `show $foo[2..5]` prints "2 b c"
- `show $foo[1 3 7 2]` prints "3 a c b"

and similar for command substitutions.

Fixes #826.
2017-06-20 17:52:23 -07:00
Andreas Nordal
08d42a0507 Error message prefix: Prefix the message, not the context
Fixes #3649
2017-04-11 20:00:29 -07:00
ridiculousfish
534fd1a59e Pass the character index, not the character, to parse_util_expand_variable_error
Fixes #2067
2015-05-15 17:56:12 -07:00
Kevin Ballard
2974025010 Fix error span for invalid slice indexes
The span now properly points at the token that was invalid, rather than
the start of the slice.

Also fix the span for `()[1]` and `()[d]`, which were previously
reporting no source location at all.
2014-08-21 01:10:07 -07:00
Kevin Ballard
cc49042294 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.
2014-08-20 22:09:32 -07:00
Kevin Ballard
3981b644d6 Fix double expansions ($$foo)
Double expansions of variables had the following issues:

* `"$$foo"` threw an error no matter what the value of `$foo` was.
* `set -l foo ''; echo $$foo` threw an error because of the expansion of
  `$foo` to `''`.

With this change, double expansion always works properly. When
double-expanding a multi-valued variable, in a double-quoted string the
first word of the inner expansion is used for the outer expansion, and
outside of a quoted string every word is used for the double-expansion
in each of the arguments.

    > set -l foo bar baz
    > set -l bar one two
    > set -l baz three four
    > echo "$$foo"
    one two baz
    > echo $$foo
    one two three four
2014-08-20 21:45:07 -07:00