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

Method JobIDExpand

shell/shell.go:443–462  ·  view source on GitHub ↗

JobIDExpand expands %n job id values in args with the full PID returns number of PIDs expanded

(args []string)

Source from the content-addressed store, hash-verified

441// JobIDExpand expands %n job id values in args with the full PID
442// returns number of PIDs expanded
443func (sh *Shell) JobIDExpand(args []string) int {
444 exp := 0
445 for i, id := range args {
446 if id[0] == '%' {
447 idx, err := strconv.Atoi(id[1:])
448 if err == nil {
449 if idx > 0 && idx <= len(sh.Jobs) {
450 jb := sh.Jobs[idx-1]
451 if jb.Cmd != nil && jb.Cmd.Process != nil {
452 args[i] = fmt.Sprintf("%d", jb.Cmd.Process.Pid)
453 exp++
454 }
455 } else {
456 sh.AddError(fmt.Errorf("cosh: job number out of range: %d", idx))
457 }
458 }
459 }
460 }
461 return exp
462}

Callers 2

KillMethod · 0.95
FgMethod · 0.95

Calls 2

AddErrorMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected