MCPcopy Index your code
hub / github.com/containers/toolbox / runCommandWithFallbacks

Function runCommandWithFallbacks

src/cmd/run.go:357–490  ·  view source on GitHub ↗
(container string,
	preserveFDs uint,
	command, environ []string,
	emitEscapeSequence, fallbackToBash bool)

Source from the content-addressed store, hash-verified

355}
356
357func runCommandWithFallbacks(container string,
358 preserveFDs uint,
359 command, environ []string,
360 emitEscapeSequence, fallbackToBash bool) error {
361
362 logrus.Debug("Checking if 'podman exec' supports disabling the detach keys")
363
364 var detachKeysSupported bool
365
366 if podman.CheckVersion("1.8.1") {
367 logrus.Debug("'podman exec' supports disabling the detach keys")
368 detachKeysSupported = true
369 }
370
371 envOptions := utils.GetEnvOptionsForPreservedVariables()
372 for _, env := range environ {
373 logrus.Debugf("%s", env)
374 envOption := "--env=" + env
375 envOptions = append(envOptions, envOption)
376 }
377
378 preserveFDsString := fmt.Sprint(preserveFDs)
379
380 var stderr io.Writer
381 var ttyNeeded bool
382
383 if term.IsTerminal(os.Stdin) && term.IsTerminal(os.Stdout) {
384 ttyNeeded = true
385 if logLevel := logrus.GetLevel(); logLevel >= logrus.DebugLevel {
386 stderr = os.Stderr
387 }
388 } else {
389 stderr = os.Stderr
390 }
391
392 runFallbackCommandsIndex := 0
393 runFallbackWorkDirsIndex := 0
394 workDir := workingDirectory
395
396 for {
397 execArgs := constructExecArgs(container,
398 preserveFDsString,
399 command,
400 detachKeysSupported,
401 envOptions,
402 fallbackToBash,
403 ttyNeeded,
404 workDir)
405
406 if emitEscapeSequence {
407 fmt.Printf("\033]777;container;push;%s;toolbox;%s\033\\", container, currentUser.Uid)
408 }
409
410 logrus.Debugf("Running in container %s:", container)
411 logrus.Debug("podman")
412 for _, arg := range execArgs {
413 logrus.Debugf("%s", arg)
414 }

Callers 1

runCommandFunction · 0.85

Calls 4

constructExecArgsFunction · 0.85
isPathPresentFunction · 0.85
getCurrentUserHomeDirFunction · 0.85
isCommandPresentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…