Commit Graph

37 Commits

Author SHA1 Message Date
David Adam
d6a4694d9f tests: add test for invalid variable name in for loop
Work on #5800.
2019-04-09 20:10:57 +08:00
ridiculousfish
9454397e4c Correctly split path environment variables about colons
As noted in #5271
2018-10-27 15:20:32 -07:00
ridiculousfish
5899694233 Allow setting universal path variables
Support for path and unpath in universal variables.
Fixes #5271
2018-10-27 01:05:00 -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
3f3b3a7006 Export arrays as colon delimited, and support path-style variables
This commit begins to bake in a notion of path-style variables.

Prior to this fix, fish would export arrays as ASCII record separator
delimited, except for a whitelist (PATH, CDPATH, MANPATH). This is
surprising and awkward for other programs to deal with, and there's no way
to get similar behavior for other variables like GOPATH or LD_LIBRARY_PATH.

This commit does the following:

1. Exports all arrays as colon delimited strings, instead of RS.

2. Introduces a notion of "path variable." A path variable will be
"colon-delimited" which means it gets colon-separated in quoted expansion,
and automatically splits on colons. In this commit we only do the exporting
part.

Colons are not escaped in exporting; this is deliberate to support uses
like

    `set -x PYTHONPATH "/foo:/bar"`

which ought to work (and already do, we don't want  to make a compat break
here).
2018-10-19 17:29:39 -07:00
Aaron Gyes
a9283803d4 Revert "Non-exported vars: rename SHLVL to shlvl"
Duh, of course it is exported.

This reverts commit 5fc17dcc82.
2017-10-15 04:37:34 -07:00
Aaron Gyes
5fc17dcc82 Non-exported vars: rename SHLVL to shlvl
Fixes #4414
2017-10-15 04:33:27 -07:00
Kurtis Rader
f872f25f5b change env_var_t to a vector of strings
Internally fish should store vars as a vector of elements. The current
flat string representation is a holdover from when the code was written
in C.

Fixes #4200
2017-08-18 16:24:30 -07:00
Fabian Homborg
427b8f5c52 Comment and test that we shouldn't copy for blocks
Seems important.
2017-07-20 18:25:18 -07:00
Fabian Homborg
f2a6ae20e5 Test copying local-exported vars 2017-07-20 18:25:18 -07:00
Fabian Homborg
9ca6cb9fc8 Test that exported vars remain exported
I.e. the fix for #2611.
2017-07-20 18:25:18 -07:00
Kurtis Rader
d51f82d1b5 fix bug in test3
The change for issue #4163 brought to light a bug in tests/test.in.
2017-07-03 15:36:38 -07:00
Kurtis Rader
b759ba8a3d harden test3 against undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 15:21:42 -07:00
Fabian Homborg
c0d80ab996 Tighten MANPATH test
This is to fix tests on Travis, since that stores the commit message in an environment variable.

`env | grep MANPATH` of course picks it up and generates unwanted output.

Yes.
2017-04-18 22:42:38 +02:00
Kurtis Rader
c272584fec a step to remove __fish_sgrep per issue #2450 2017-04-11 21:46:46 -07:00
Kurtis Rader
8b67a1b26f make testing on local servers hermetic
I noticed while fixing issue #2702 that the fish program being tested
was sourcing config.fish files outside of the current build. This also
happens when Travis CI runs the tests but isn't an issue there because
of how Travis is configured to execute the tests.

I also noticed that running `make test` was polluting my personal fish
history; which will become a bigger problem if and when the fishd universal
var file is moved from $XDG_CONFIG_HOME to $XDG_DATA_HOME.

This change makes it possible for an individual to run the tests on
their local machine secure in the knowledge that only the config.fish and
related files from their git repository will be used and doing so won't
pollute their personal fish history.

Resolves #469
2016-02-25 17:16:36 -08:00
Fabian Homborg
b85a8bbbfe Rename sgrep to __fish_sgrep
Makes it harder to cause issues with aliases, see fish-shell#2245
2015-09-09 20:55:04 +02:00
ridiculousfish
f3560b8e62 Correctly un-export an env var when it is shadowed
Prior to this fix, if you exported a variable in one scope
and then unexported it in the next, it would remain exported.
Example:

    set -gx VAR 1
    function foo; set -l VAR; env; end
    foo

Here 'VAR' would be exported to 'env' because we failed to
notice that the env var is shadowed by an unexported variable.
This occurred at env var computation time, not in env_set!

Fixes #2132
2015-06-12 16:05:59 -07:00
ridiculousfish
f30872a7b5 Recalculate exported variables when universal variable is erased
Fixes #2046
2015-04-29 17:28:49 -07:00
ridiculousfish
d7ba6e4a1d Properly fire events for universal variable changes
Fixes #1929
2015-02-03 16:13:02 -08:00
ridiculousfish
c0b8e81b02 Change how arrays and environment variables interact.
Prior to this change, inherited environment variables
would be split on colons, becoming an array. This change
eliminates that behavior. Now environment variables are
always split on the record separator character (ASCII 0x1e),
with the exception of a short whitelist of PATH, MANPATH,
CDPATH. Likewise, exported variables are also exported
delimited by rs, with the exception of the above whitelist.

Fixes #1374, also see #1656
2014-10-12 15:01:44 -07:00
Kevin Ballard
a13e067b85 Fix test breakage from 14724401f
We can't use $PATHS to test the :-splitting because the global config
file adds extra paths based on /etc/paths and /etc/paths.d.

Ideally fish would have a way to suppress behavior like that, but for
the time being it doesn't.
2014-10-07 19:37:13 -07:00
David Adam
14724401ff env.cpp: correctly check variable_can_be_array
Closes #1746.
2014-10-08 09:53:29 +08:00
Kevin Ballard
940f264ee6 Decrement SHLVL when running exec
`exec` removes fish from the shell "stack", so SHLVL needs to be
decremented to match. This means `exec fish` will result in the same
SHLVL in the new fish instance.

Also tweak the SHLVL logic to interpret an environment SHLVL of "3foo"
as garbage instead of as the value "3".

Fixes #1693.
2014-09-19 17:38:54 -07:00
Kevin Ballard
130619d6b0 Fix $SHLVL
Due to being read-only, SHLVL wasn't being incremented properly for
recursive invocations of fish.
2014-08-29 12:22:35 -07:00
ridiculousfish
18c1b12741 Switch variable name in tests from foo to something less likely to be
used accidentally
2014-07-06 20:41:21 -07:00
ridiculousfish
b19f45e15d Add test for issue 1526 2014-07-06 18:12:18 -07:00
Jan Kanis
9ee7b0a501 really fix bug in export status of universal vars; add tests for that bug 2013-01-02 23:31:30 -08:00
ridiculousfish
39863ce4d7 Fix for longstanding bug where set -e would fail to erase elements from an array.
This was introduced in 7b3377e78c
2012-05-10 01:04:18 -07:00
Grissiom
70322077d2 remove trialing spaces #2 2010-09-18 10:18:26 +08:00
axel
bef7fff383 Do not test universal variable functionality since it relies on fish to be installed
darcs-hash:20060718173711-ac50b-1feae98c4c283bfa5bbc8dfedec3eb4641316a8d.gz
2006-07-19 03:37:11 +10:00
axel
20e5d298a0 Updates, bugfixing and minor edits on the test suite
darcs-hash:20060605133133-ac50b-e2ee5868f9f3ede147c7059d90c0f520ed905a5f.gz
2006-06-05 23:31:33 +10:00
axel
2fab5364e1 Fix broken regression test (irony?)
darcs-hash:20051002134406-ac50b-d9d3c94eb08ecd05be1a4e128ca08d9d3ae53978.gz
2005-10-02 23:44:06 +10:00
axel
1ecfc8e4c6 Minor fix in testsuite
darcs-hash:20050927174025-ac50b-554f6bf9aefc2da0b5a40baebb44bcd02a933704.gz
2005-09-28 03:40:25 +10:00
axel
e855f2dfc9 Update testsuite to reflect new variable scoping rules
darcs-hash:20050927083554-ac50b-80f5fcb0022416a80eb8d3aa673282a2c67d4dd4.gz
2005-09-27 18:35:54 +10:00
axel
6a3e73f87c Fix regression bug in regression test suite
darcs-hash:20050926141136-ac50b-864add3824c34e96ad56bc0e92537196992692b0.gz
2005-09-27 00:11:36 +10:00
axel
7ddecde543 Add subdirectories
darcs-hash:20050920133155-ac50b-9a14c6c664dd03afbe8e15e7c7998fcfb5c3c750.gz
2005-09-20 23:31:55 +10:00