Пример #1
0
func TestPath(t *testing.T) {
	t.Logf("path %v", cmd.GetEnvList("path"))
	t.Logf("path %v", cmd.GetEnv("PATH"))
	t.Logf("path %v", cmd.Path())
	if p := cmd.LookPath("sh"); p != "/bin/sh" {
		t.Fatalf("sh is %q\n", p)
	}
	if p := cmd.LookPath("./sh"); p != "" {
		t.Fatalf("sh is %q\n", p)
	}
}
Пример #2
0
func btype(x *xEnv, args ...string) error {
	for _, a := range args[1:] {
		found := false
		if getFunc(a) != nil {
			x.Printf("%s: func\n", a)
			found = true
		}
		if builtins[a] != nil {
			x.Printf("%s: builtin\n", a)
			found = true
		}
		if p := cmd.LookPath(a); p != "" {
			x.Printf("%s: %s\n", a, p)
		} else if !found {
			x.Printf("%s: unknown\n", a)
		}
	}
	return nil
}