From 0c08a42ac846cf29fd026f5f0c1499bfa8220978 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Thu, 26 Mar 2020 22:58:24 -0400 Subject: [PATCH] cmd/run: Don't break GNU Readline's ctrl-p shortcut Podman sets 'ctrl-p ctrl-q' as the default key sequence for detaching a container. This breaks the ctrl-p shortcut that's equivalent to the up arrow key in GNU Readline environments like Bash and Emacs. Moreoever, toolbox containers aren't meant to be detached in the first place. Since Podman 1.8.1, it is now possible to unset the key sequence for detaching [2, 3]. [0] https://tiswww.cwru.edu/php/chet/readline/readline.html#SEC15 [1] https://www.gnu.org/software/emacs/tour/ [2] Podman commit 7c623bd41ff3d534 https://github.com/containers/podman/issues/4208 [3] Podman commit ebfd253fc658ffc9 https://github.com/containers/podman/issues/5166 https://github.com/containers/toolbox/issues/394 --- src/cmd/run.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cmd/run.go b/src/cmd/run.go index 553220863..412e3fe8e 100644 --- a/src/cmd/run.go +++ b/src/cmd/run.go @@ -269,17 +269,31 @@ func runCommand(container string, } } + logrus.Debug("Checking if 'podman exec' supports disabling the detach keys") + + var detachKeys []string + + if podman.CheckVersion("1.8.1") { + logrus.Debug("'podman exec' supports disabling the detach keys") + detachKeys = []string{"--detach-keys", ""} + } + envOptions := utils.GetEnvOptionsForPreservedVariables() logLevelString := podman.LogLevel.String() execArgs := []string{ "--log-level", logLevelString, "exec", + } + + execArgs = append(execArgs, detachKeys...) + + execArgs = append(execArgs, []string{ "--interactive", "--tty", "--user", currentUser.Username, "--workdir", workingDirectory, - } + }...) execArgs = append(execArgs, envOptions...)