Fg foregrounds a job by job number
(cmdIO *exec.CmdIO, args ...string)
| 102 | |
| 103 | // Fg foregrounds a job by job number |
| 104 | func (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. |
| 126 | func (sh *Shell) AddPath(cmdIO *exec.CmdIO, args ...string) error { |
nothing calls this directly
no test coverage detected