diff --git a/base/aaa/role.go b/base/aaa/role.go index 984cc17d..358caf4a 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -11,7 +11,7 @@ import ( ) func _role_keys(key ...string) string { - return strings.TrimPrefix(strings.TrimSuffix(strings.ReplaceAll(path.Join(strings.ReplaceAll(kit.Keys(key), ice.PT, ice.PS)), ice.PS, ice.PT), ice.PT), ice.PT) + return strings.TrimPrefix(strings.TrimSuffix(strings.Replace(path.Join(strings.Replace(kit.Keys(key), ice.PT, ice.PS, -1)), ice.PS, ice.PT, -1), ice.PT), ice.PT) } func _role_set(m *ice.Message, role, zone, key string, status bool) { m.Logs(mdb.INSERT, mdb.KEY, "aaa.role", ROLE, role, zone, key) diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 130b4926..710f1958 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -34,8 +34,8 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) { mdb.HashSelectUpdate(m, h, func(value ice.Map) { value[PID] = cmd.Process.Pid }) m.Echo("%d", cmd.Process.Pid) m.Go(func() { - if e := cmd.Wait(); !m.Warn(e, ice.ErrNotStart, cmd.Args) && cmd.ProcessState.ExitCode() == 0 { - m.Cost(CODE, cmd.ProcessState.ExitCode(), ctx.ARGS, cmd.Args) + if e := cmd.Wait(); !m.Warn(e, ice.ErrNotStart, cmd.Args) && cmd.ProcessState.Success() { + m.Cost(CODE, "0", ctx.ARGS, cmd.Args) mdb.HashModify(m, mdb.HASH, h, STATUS, STOP) } else { mdb.HashSelectUpdate(m, h, func(value ice.Map) { diff --git a/base/cli/system.go b/base/cli/system.go index 03b0a8ab..76d6d0ef 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -97,9 +97,9 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) { }() } if e := cmd.Run(); !m.Warn(e, ice.ErrNotFound, cmd.Args) { - m.Cost(CODE, cmd.ProcessState.ExitCode(), ctx.ARGS, cmd.Args) + m.Cost(CODE, cmd.ProcessState.Success(), ctx.ARGS, cmd.Args) } - m.Push(mdb.TIME, m.Time()).Push(CODE, int(cmd.ProcessState.ExitCode())) + m.Push(mdb.TIME, m.Time()).Push(CODE, kit.Select("1", "0", cmd.ProcessState.Success())) } func _system_find(m Message, bin string, dir ...string) string { if strings.Contains(bin, ice.DF) { diff --git a/base/yac/matrix.go b/base/yac/matrix.go index f23a4544..557ba862 100644 --- a/base/yac/matrix.go +++ b/base/yac/matrix.go @@ -375,7 +375,7 @@ func init() { mat.mat[page] = make([]*State, mat.ncell) } - m.Option(mdb.TEXT, strings.ReplaceAll(m.Option(mdb.TEXT), "\\", "\\\\")) + m.Option(mdb.TEXT, strings.Replace(m.Option(mdb.TEXT), "\\", "\\\\", -1)) text := kit.Split(m.Option(mdb.TEXT), " ", " ", " ") mat.train(m, page, hash, text, 1) mdb.Grow(m, m.PrefixKey(), kit.Keys(mdb.HASH, key), kit.Dict( diff --git a/base/yac/script.go b/base/yac/script.go index 8722e6df..55f77339 100644 --- a/base/yac/script.go +++ b/base/yac/script.go @@ -103,12 +103,12 @@ func init() { m.Option(mdb.TEXT, string(buf)) } - m.Option(mdb.TEXT, strings.ReplaceAll(m.Option(mdb.TEXT), "\\", "\\\\")) + m.Option(mdb.TEXT, strings.Replace(m.Option(mdb.TEXT), "\\", "\\\\", -1)) for _, line := range kit.Split(m.Option(mdb.TEXT), "\n", "\n", "\n") { if strings.HasPrefix(strings.TrimSpace(line), "#") { continue } - line = strings.ReplaceAll(line, "\\", "\\\\") + line = strings.Replace(line, "\\", "\\\\", -1) if list := kit.Split(line, " ", " ", " "); len(list) > 2 { m.Cmdx(MATRIX, mdb.INSERT, m.Option(mdb.NAME), list[0], list[1], strings.Join(list[2:], " ")) } @@ -149,7 +149,7 @@ func init() { if e1 == nil && e2 == nil { m.Echo("%d", n1-n2) } else { - m.Echo("%s", strings.ReplaceAll(arg[0], arg[2], "")) + m.Echo("%s", strings.Replace(arg[0], arg[2], "", -1)) } case "*": if e1 == nil && e2 == nil { @@ -161,7 +161,7 @@ func init() { if e1 == nil && e2 == nil { m.Echo("%d", n1/n2) } else { - m.Echo("%s", strings.ReplaceAll(arg[0], arg[2], "")) + m.Echo("%s", strings.Replace(arg[0], arg[2], "", -1)) } case "%": if e1 == nil && e2 == nil { diff --git a/core/chat/div.go b/core/chat/div.go index 46f60ad9..62bf7895 100644 --- a/core/chat/div.go +++ b/core/chat/div.go @@ -31,9 +31,9 @@ func init() { case nfs.HTML: m.RenderDownload(p) case nfs.CSS: - m.RenderResult(_div_template, m.Cmdx(nfs.CAT, p), m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".css", ".js"))) + m.RenderResult(_div_template, m.Cmdx(nfs.CAT, p), m.Cmdx(nfs.CAT, strings.Replace(p, ".css", ".js", -1))) case nfs.JS: - m.RenderResult(_div_template, m.Cmdx(nfs.CAT, strings.ReplaceAll(p, ".js", ".css")), m.Cmdx(nfs.CAT, p)) + m.RenderResult(_div_template, m.Cmdx(nfs.CAT, strings.Replace(p, ".js", ".css", -1)), m.Cmdx(nfs.CAT, p)) case nfs.JSON: m.RenderResult(_div_template2, kit.Format(kit.UnMarshal(m.Cmdx(nfs.CAT, p)))) default: diff --git a/core/chat/oauth/oauth.go b/core/chat/oauth/oauth.go index 4b976938..1f5d5a1b 100644 --- a/core/chat/oauth/oauth.go +++ b/core/chat/oauth/oauth.go @@ -28,7 +28,7 @@ func _merge_url(m *ice.Message, domain, key string, arg ...ice.Any) string { if domain = strings.TrimSuffix(domain, ice.PS); strings.Contains(domain, "/chat/pod/") { domain += web.P(strings.TrimPrefix(m.Prefix(web.P(key)), "web.chat.")) } else { - domain += path.Join(strings.TrimPrefix(strings.ReplaceAll(m.Target().Cap(ice.CTX_FOLLOW), ice.PT, ice.PS), "web"), path.Join(key)) + domain += path.Join(strings.TrimPrefix(strings.Replace(m.Target().Cap(ice.CTX_FOLLOW), ice.PT, ice.PS, -1), "web"), path.Join(key)) } return kit.MergeURL(domain, arg...) } diff --git a/core/code/js.go b/core/code/js.go index c7c36f26..457449a8 100644 --- a/core/code/js.go +++ b/core/code/js.go @@ -75,7 +75,7 @@ func _js_show(m *ice.Message, arg ...string) { } func _js_exec(m *ice.Message, arg ...string) { if arg[2] == "usr/volcanos/" && strings.HasPrefix(arg[1], "plugin/local/") { - key := "web." + strings.ReplaceAll(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), ".js"), ice.PS, ice.PT) + key := "web." + strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), ".js"), ice.PS, ice.PT, -1) ctx.ProcessCommand(m, kit.Select("can.plugin", key), kit.Simple()) return } @@ -102,7 +102,7 @@ func init() { if len(arg) > 0 && arg[0] == mdb.FOREACH { // 文件 switch m.Option(ctx.ACTION) { case nfs.SCRIPT: - m.Push(nfs.PATH, strings.ReplaceAll(arg[1], ice.PT+kit.Ext(arg[1]), ice.PT+JS)) + m.Push(nfs.PATH, strings.Replace(arg[1], ice.PT+kit.Ext(arg[1]), ice.PT+JS, -1)) m.Option(nfs.DIR_REG, kit.FileReg(nfs.SH, nfs.PY, nfs.SHY, nfs.JS)) nfs.DirDeepAll(m, ice.SRC, nfs.PWD, nil).Cut(nfs.PATH) } diff --git a/core/wiki/field.go b/core/wiki/field.go index e2073db2..48623190 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -38,7 +38,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) { if len(meta) == 0 || !aaa.Right(m.Spawn(), cmds[0]) { return } - name = strings.ReplaceAll(name, ice.SP, "_") + name = strings.Replace(name, ice.SP, "_", -1) meta[mdb.NAME], meta[mdb.INDEX] = name, text msg := m.Spawn() for i := 0; i < len(arg)-1; i += 2 { diff --git a/core/wiki/table.go b/core/wiki/table.go index 0a33696d..dcfa3a2d 100644 --- a/core/wiki/table.go +++ b/core/wiki/table.go @@ -26,7 +26,7 @@ func _table_run(m *ice.Message, arg ...string) { func _table_show(m *ice.Message, text string, arg ...string) { head, list := []string{}, [][]string{} for i, line := range kit.SplitLine(text) { - if line = strings.ReplaceAll(line, "%", "%%"); i == 0 { + if line = strings.Replace(line, "%", "%%", -1); i == 0 { head = kit.SplitWord(line) continue } diff --git a/misc/git/status.go b/misc/git/status.go index 38ed57ab..712f9332 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -60,7 +60,7 @@ func _status_tags(m *ice.Message) { } if v, ok := vs[kit.Select("", strings.Split(ls[0], ice.PS), -1)]; ok && ls[1] != v { m.Logs(mdb.MODIFY, REPOS, ls[0], "from", ls[1], "to", v) - text, change = strings.ReplaceAll(text, ls[1], v), true + text, change = strings.Replace(text, ls[1], v, -1), true } return text })