fix setenv and add unit tests

Fixes #3937
This commit is contained in:
Kurtis Rader
2017-04-04 23:26:06 -07:00
parent 35e1d1e2d8
commit 75600b6b53
4 changed files with 62 additions and 16 deletions

20
tests/setenv.in Normal file
View File

@@ -0,0 +1,20 @@
# Verify the correct behavior of the `setenv` compatibility shim.
# No args to `setenv` should emit the current set of env vars. The first two
# commands verify that `setenv` does not report non-env vars.
set -g setenv1 abc
setenv | grep '^setenv1=$'
set -gx setenv1 xyz
setenv | grep '^setenv1=xyz$'
# A single arg should set and export the named var to nothing.
setenv setenv2
env | grep '^setenv2=$'
# Three or more args should be an error.
echo too many arguments test >&2
setenv var hello you
# Two args should set the named var to the second arg
setenv setenv3 'hello you'
setenv | grep '^setenv3=hello you'