From 62734c38b082eeca2f696fe47507a04a2b5cda2c Mon Sep 17 00:00:00 2001 From: Jonathan Yu Date: Sun, 24 Jan 2021 00:53:14 +0000 Subject: [PATCH] fix: Force bash for non-standard flags to exec This addresses a regression introduced by #224. POSIX sh does not define arguments to the exec built-in, resulting in an error when using 'exec -a' to set the process name (argv[0]). This change executes /bin/bash instead of sh, and also changes to use 'exec -l', which automatically handles the hyphen prefix required to trigger login shell behavior. This also explicitly runs /bin/sh, aligning the behavior of "coder sh" and the frontend Terminal application. --- internal/cmd/shell.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/cmd/shell.go b/internal/cmd/shell.go index 17b0ee27..6b647b70 100644 --- a/internal/cmd/shell.go +++ b/internal/cmd/shell.go @@ -82,15 +82,20 @@ coder sh front-end-dev cat ~/config.json`, func shell(cmd *cobra.Command, cmdArgs []string) error { ctx := cmd.Context() - command := "sh" - args := []string{"-c"} + var command string + var args []string if len(cmdArgs) > 1 { + command = "/bin/sh" + args = []string{"-c"} args = append(args, strings.Join(cmdArgs[1:], " ")) } else { // Bring user into shell if no command is specified. shell := "$(getent passwd $(id -u) | cut -d: -f 7)" - name := "-$(basename " + shell + ")" - args = append(args, fmt.Sprintf("exec -a %q %q", name, shell)) + + // force bash for the '-l' flag to the exec built-in + command = "/bin/bash" + args = []string{"-c"} + args = append(args, fmt.Sprintf("exec -l %q", shell)) } envName := cmdArgs[0] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy