forked from x/icebergs
opt some
This commit is contained in:
parent
4cfa425690
commit
52d581c4b5
@ -14,7 +14,6 @@ import (
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/file"
|
||||
"shylinux.com/x/toolkits/logs"
|
||||
)
|
||||
|
||||
func _path_split(ps string) []string {
|
||||
@ -25,7 +24,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
bin, env := "", kit.Simple(m.Optionv(CMD_ENV))
|
||||
for i := 0; i < len(env)-1; i += 2 {
|
||||
if env[i] == PATH {
|
||||
logs.Println("what")
|
||||
if bin = _system_find(m, arg[0], _path_split(env[i+1])...); bin != "" {
|
||||
m.Logs(mdb.SELECT, "envpath cmd", bin)
|
||||
}
|
||||
@ -33,33 +31,28 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
}
|
||||
if bin == "" {
|
||||
if text := kit.ReadFile(ice.ETC_PATH); len(text) > 0 {
|
||||
logs.Println("what")
|
||||
if bin = _system_find(m, arg[0], strings.Split(text, ice.NL)...); bin != "" {
|
||||
m.Logs(mdb.SELECT, "etcpath cmd", bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
if bin == "" {
|
||||
logs.Println("what")
|
||||
if bin = _system_find(m, arg[0], ice.BIN, m.Option(CMD_DIR)); bin != "" {
|
||||
m.Logs(mdb.SELECT, "contexts cmd", bin)
|
||||
}
|
||||
}
|
||||
if bin == "" {
|
||||
logs.Println("what")
|
||||
if bin = _system_find(m, arg[0], ice.BIN, nfs.PWD); bin != "" {
|
||||
m.Logs(mdb.SELECT, "contexts cmd", bin)
|
||||
}
|
||||
}
|
||||
if bin == "" && !strings.Contains(arg[0], ice.PS) {
|
||||
logs.Println("what %s", arg[0])
|
||||
if bin = _system_find(m, arg[0]); bin != "" {
|
||||
m.Logs(mdb.SELECT, "systems cmd", bin)
|
||||
}
|
||||
}
|
||||
if bin == "" && !strings.Contains(arg[0], ice.PS) {
|
||||
m.Cmd(MIRRORS, CMD, arg[0])
|
||||
logs.Println("what")
|
||||
if bin = _system_find(m, arg[0]); bin != "" {
|
||||
m.Logs(mdb.SELECT, "mirrors cmd", bin)
|
||||
}
|
||||
@ -67,7 +60,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
if bin == "" && runtime.GOOS == WINDOWS {
|
||||
bin = path.Join("C:/Windows", arg[0])
|
||||
}
|
||||
logs.Println("what %s %s", bin, arg)
|
||||
cmd := exec.Command(bin, arg[1:]...)
|
||||
if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 {
|
||||
if m.Logs(mdb.PARAMS, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
||||
@ -133,9 +125,7 @@ func _system_find(m Message, bin string, dir ...string) string {
|
||||
if len(dir) == 0 {
|
||||
dir = append(dir, _path_split(kit.Env(PATH))...)
|
||||
}
|
||||
logs.Println("what %s", dir)
|
||||
for _, p := range dir {
|
||||
logs.Println("what %s", path.Join(p, bin))
|
||||
if nfs.ExistsFile(m, path.Join(p, bin)) {
|
||||
return kit.Path(p, bin)
|
||||
}
|
||||
@ -189,9 +179,7 @@ func init() {
|
||||
mdb.HashSelect(m)
|
||||
return
|
||||
}
|
||||
// mdb.HashCreate(m.Spawn(), ice.CMD, arg[0], ice.ARG, kit.Join(arg[1:], ice.SP))
|
||||
if _system_exec(m, _system_cmd(m, arg...)); IsSuccess(m) && m.Append(CMD_ERR) == "" {
|
||||
// if _system_exec(m, _system_cmd(m, kit.Simple(kit.Split(arg[0]), arg[1:])...)); IsSuccess(m) && m.Append(CMD_ERR) == "" {
|
||||
m.SetAppend()
|
||||
}
|
||||
}},
|
||||
|
@ -118,7 +118,7 @@ func init() {
|
||||
|
||||
var _contexts = kit.Dict(
|
||||
ice.MISC, `
|
||||
export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp app username {{.Option "user.name"}} usernick {{.Option "user.nick"}}
|
||||
export ctx_dev={{.Option "domain"}}{{.Option "ctx_env"}}; temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp app username {{.Option "user.name"}} usernick "{{.Option "user.nick"}}"
|
||||
`,
|
||||
ice.CORE, `
|
||||
temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL {{.Option "domain"}}; else wget -O $temp -q {{.Option "domain"}}; fi; source $temp binary
|
||||
|
Loading…
x
Reference in New Issue
Block a user