var err error
var usage string
- xs := strings.Split(l, " ")
+ xs := strings.Fields(l)
switch xs[0] {
case "net":
usage = `"net" <name> <prefix>...`
err = parseConfigLink(&cfg, xs[1:])
case "cmd":
usage = `"cmd" <string-passed-to-sh-c>`
- err = parseConfigCmd(&cfg, xs[1:])
+ x := strings.TrimSpace(strings.TrimPrefix(l, "cmd"))
+ err = parseConfigCmd(&cfg, x)
default:
usage = `"net" | "node" | "link" | "cmd"`
err = fmt.Errorf("unknown option %q", xs[0])
return nil
}
-func parseConfigCmd(cfg *Config, args []string) error {
- if len(args) < 1 {
+func parseConfigCmd(cfg *Config, cmd string) error {
+ if len(cmd) == 0 {
return fmt.Errorf("not enough arguments")
}
- cfg.Cmds = append(cfg.Cmds, strings.Join(args, " "))
+ cfg.Cmds = append(cfg.Cmds, cmd)
return nil
}