summaryrefslogtreecommitdiff
path: root/cmds/env.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/env.go')
-rw-r--r--cmds/env.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/cmds/env.go b/cmds/env.go
index 17b220d..63ee7f6 100644
--- a/cmds/env.go
+++ b/cmds/env.go
@@ -36,23 +36,26 @@ func Set(args []string) {
}
// unset: unsets an environment variable
-func Unset(args []string) error {
+func Unset(args []string) (int, error) {
if len(args) == 1 || len(args) >= 3 {
- return errors.New("usage: unset [name]")
+ return 1, errors.New("usage: unset [name]")
}
os.Unsetenv(args[1])
- return nil
+ return 0, nil
}
// export: exports a key-value pair to the environment
// in the form of `name=value`
-func Export(args []string) error {
+func Export(args []string) (int, error) {
if len(args) == 1 || len(args) >= 3 {
- return errors.New("usage: export [name=value]")
+ return 1, errors.New("usage: export [name=value]")
}
tmp := strings.Split(args[1], "=")
if len(tmp) != 2 {
- return errors.New("usage: export [name=value]")
+ return 1, errors.New("usage: export [name=value]")
}
- return os.Setenv(tmp[0], tmp[1])
+ if err := os.Setenv(tmp[0], tmp[1]); err != nil {
+ return 2, err
+ }
+ return 0, nil
}