diff options
Diffstat (limited to 'cmds/cmds.go')
-rw-r--r-- | cmds/cmds.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/cmds/cmds.go b/cmds/cmds.go index 6d4d895..0cfee5e 100644 --- a/cmds/cmds.go +++ b/cmds/cmds.go @@ -1,11 +1,11 @@ +// cmds: handles system commands package cmds -import ( - "errors" - "os" - "strings" -) +import "strings" +// Eval: evaluates a provided string into a command +// if it can't find the command or the arguments are incorrect +// returns an error func Eval(cmd string) error { args := strings.Split(cmd, " ") switch args[0] { @@ -20,16 +20,15 @@ func Eval(cmd string) error { } break case "unset": - if len(args) == 1 || len(args) >= 3 { - return errors.New("usage: unset {name}") + if err := unset(args); err != nil { + return err } - os.Unsetenv(args[1]) break case "set": if len(args) > 1 { set(args) } else { - printenv() + printEnv() } break case "exit": |