Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

fix: Force bash for non-standard flags to exec #226

Merged
merged 1 commit into from
Jan 25, 2021
Merged

Conversation

jawnsy
Copy link
Contributor

@jawnsy jawnsy commented Jan 24, 2021

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.

Tested this using Arch Linux (enterprise-dev image) as well as the base Debian image from DockerHub.

[coder@jawnsy-m coder-cli]$ go install ./cmd/coder
[coder@jawnsy-m coder-cli]$ which coder
/home/coder/go/bin/coder
[coder@jawnsy-m coder-cli]$ coder sh jawnsy-m
warning: version mismatch detected
  | Coder CLI version: unknown
  | Coder API version: 1.14.0+340-gd64a44cb3-20210123
  | 
  | tip: download the appropriate version here: https://github.com/cdr/coder-cli/releases
[coder@jawnsy-m ~]$ shopt login_shell
login_shell     on
[coder@jawnsy-m ~]$ exit
logout
[coder@jawnsy-m coder-cli]$ coder sh jawnsy-debian
warning: version mismatch detected
  | Coder CLI version: unknown
  | Coder API version: 1.14.0+340-gd64a44cb3-20210123
  | 
  | tip: download the appropriate version here: https://github.com/cdr/coder-cli/releases
root@jawnsy-debian:~# shopt login_shell
login_shell     on
root@jawnsy-debian:~# exit
logout

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.
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #418: Use a login shell for terminals.

@jawnsy jawnsy self-assigned this Jan 24, 2021
@jawnsy jawnsy merged commit 51fd2d3 into master Jan 25, 2021
@jawnsy jawnsy deleted the jawnsy/ch418 branch January 25, 2021 15:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants