MCPcopy Create free account
hub / github.com/cogentcore/core / Fg

Method Fg

shell/builtins.go:104–123  ·  view source on GitHub ↗

Fg foregrounds a job by job number

(cmdIO *exec.CmdIO, args ...string)

Source from the content-addressed store, hash-verified

102
103// Fg foregrounds a job by job number
104func (sh *Shell) Fg(cmdIO *exec.CmdIO, args ...string) error {
105 if len(args) != 1 {
106 return fmt.Errorf("cosh fg: requires exactly one job id argument")
107 }
108 jid := args[0]
109 exp := sh.JobIDExpand(args)
110 if exp != 1 {
111 return fmt.Errorf("cosh fg: argument was not a job id in the form %%n")
112 }
113 jno, _ := strconv.Atoi(jid[1:]) // guaranteed good
114 job := sh.Jobs[jno]
115 cmdIO.Printf("foregrounding job [%d]\n", jno)
116 _ = job
117 // todo: the problem here is we need to change the stdio for running job
118 // job.Cmd.Wait() // wait
119 // * probably need to have wrapper StdIO for every exec so we can flexibly redirect for fg, bg commands.
120 // * likewise, need to run everything effectively as a bg job with our own explicit Wait, which we can then communicate with to move from fg to bg.
121
122 return nil
123}
124
125// AddPath adds the given path(s) to $PATH.
126func (sh *Shell) AddPath(cmdIO *exec.CmdIO, args ...string) error {

Callers

nothing calls this directly

Calls 3

JobIDExpandMethod · 0.95
ErrorfMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected