mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
pkg/program/shell: MakePathsWithDefaults -> MakePaths.
Also change it to accept and return Paths values (instead of *Paths).
This commit is contained in:
parent
094a03ac5b
commit
a2a42e2767
|
@ -17,8 +17,8 @@ type shellProgram struct {
|
|||
}
|
||||
|
||||
func (sh *shellProgram) Main(fds [3]*os.File, args []string) int {
|
||||
p := shell.MakePathsWithDefaults(fds[2],
|
||||
&shell.Paths{Bin: sh.BinPath, Sock: sh.SockPath, Db: sh.DbPath})
|
||||
p := shell.MakePaths(fds[2],
|
||||
shell.Paths{Bin: sh.BinPath, Sock: sh.SockPath, Db: sh.DbPath})
|
||||
if sh.NoRc {
|
||||
p.Rc = ""
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ type Paths struct {
|
|||
Bin string
|
||||
}
|
||||
|
||||
// MakePathsWithDefaults tries to populate empty fileds with default values.
|
||||
func MakePathsWithDefaults(stderr io.Writer, p0 *Paths) *Paths {
|
||||
p := *p0
|
||||
// MakePaths makes a populated Paths, using the given overrides.
|
||||
func MakePaths(stderr io.Writer, overrides Paths) Paths {
|
||||
p := overrides
|
||||
setDir(&p.RunDir, "secure run directory", getSecureRunDir, stderr)
|
||||
if p.RunDir != "" {
|
||||
setChild(&p.Sock, p.RunDir, "sock")
|
||||
|
@ -47,7 +47,7 @@ func MakePathsWithDefaults(stderr io.Writer, p0 *Paths) *Paths {
|
|||
fmt.Fprintln(stderr, "warning: cannot get executable path:", err)
|
||||
}
|
||||
}
|
||||
return &p
|
||||
return p
|
||||
}
|
||||
|
||||
func setDir(p *string, what string, f func() (string, error), stderr io.Writer) {
|
||||
|
|
|
@ -34,8 +34,8 @@ type ExecuteResponse struct {
|
|||
}
|
||||
|
||||
func (web *Web) Main(fds [3]*os.File, _ []string) int {
|
||||
p := shell.MakePathsWithDefaults(fds[2],
|
||||
&shell.Paths{Bin: web.BinPath, Sock: web.SockPath, Db: web.DbPath})
|
||||
p := shell.MakePaths(fds[2],
|
||||
shell.Paths{Bin: web.BinPath, Sock: web.SockPath, Db: web.DbPath})
|
||||
ev := shell.InitRuntime(fds[2], p, true)
|
||||
defer shell.CleanupRuntime(fds[2], ev)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user