From 165c5c078b41ad2ea2edbd325948ed5aa0602e06 Mon Sep 17 00:00:00 2001 From: bpc2003 Date: Sat, 24 May 2025 14:25:58 -0400 Subject: consolidate all environment variable commands into env.go --- cmds/cmds.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'cmds/cmds.go') 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": -- cgit v1.2.3