MCPcopy
hub / github.com/containers/toolbox / showManual

Function showManual

src/cmd/utils.go:508–543  ·  view source on GitHub ↗

showManual tries to open the specified manual page using man on stdout

(manual string)

Source from the content-addressed store, hash-verified

506
507// showManual tries to open the specified manual page using man on stdout
508func showManual(manual string) error {
509 manBinary, err := exec.LookPath("man")
510 if err != nil {
511 if errors.Is(err, exec.ErrNotFound) {
512 fmt.Printf("toolbox - Tool for interactive command line environments on Linux\n")
513 fmt.Printf("\n")
514 fmt.Printf("Common commands are:\n")
515
516 usage := getUsageForCommonCommands()
517 fmt.Printf("%s", usage)
518
519 fmt.Printf("\n")
520 fmt.Printf("Go to https://containertoolbx.org/ for further information.\n")
521 return nil
522 }
523
524 return errors.New("failed to look up man(1)")
525 }
526
527 manualArgs := []string{"man", manual}
528 env := os.Environ()
529
530 stderrFd := os.Stderr.Fd()
531 stderrFdInt := int(stderrFd)
532 stdoutFd := os.Stdout.Fd()
533 stdoutFdInt := int(stdoutFd)
534 if err := syscall.Dup3(stdoutFdInt, stderrFdInt, 0); err != nil {
535 return errors.New("failed to redirect standard error to standard output")
536 }
537
538 if err := syscall.Exec(manBinary, manualArgs, env); err != nil {
539 return errors.New("failed to invoke man(1)")
540 }
541
542 return nil
543}
544
545func watchContextForEventFD(ctx context.Context, eventFD int) {
546 done := ctx.Done()

Callers 9

enterHelpFunction · 0.85
helpShowManualFunction · 0.85
rootHelpFunction · 0.85
rmiHelpFunction · 0.85
runHelpFunction · 0.85
rmHelpFunction · 0.85
createHelpFunction · 0.85
initContainerHelpFunction · 0.85
listHelpFunction · 0.85

Calls 2

IsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…