MCPcopy Index your code
hub / github.com/bitfield/script / ExitStatus

Method ExitStatus

script.go:512–526  ·  view source on GitHub ↗

ExitStatus returns the integer exit status of a previous command (for example run by [Pipe.Exec]). This will be zero unless the pipe's error status is set and the error matches the pattern “exit status %d”.

()

Source from the content-addressed store, hash-verified

510// example run by [Pipe.Exec]). This will be zero unless the pipe's error
511// status is set and the error matches the pattern “exit status %d”.
512func (p *Pipe) ExitStatus() int {
513 if p.Error() == nil {
514 return 0
515 }
516 match := exitStatusPattern.FindStringSubmatch(p.Error().Error())
517 if len(match) < 2 {
518 return 0
519 }
520 status, err := strconv.Atoi(match[1])
521 if err != nil {
522 // This seems unlikely, but...
523 return 0
524 }
525 return status
526}
527
528// Filter sends the contents of the pipe to the function filter and produces
529// the result. filter takes an [io.Reader] to read its input from and an

Calls 1

ErrorMethod · 0.95