File tree 4 files changed +42
-0
lines changed
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ sh
Original file line number Diff line number Diff line change
1
+ build :
2
+ go build sh.go
Original file line number Diff line number Diff line change
1
+ ## Go bash wrapper
2
+
3
+ - Forwards CLI arguments to ` /bin/bash `
4
+ - Fails if there is ` GO_SH_WRAPPER ` variable defined as recursion
5
+ control variable
6
+
7
+ ## But, why?
8
+
9
+ Amazon ssm-agent by default runs with 'sh' command and such does
10
+ not load full bash shell, and does not process user home-directory
11
+ startup files like ` ~/.bashrc `
12
+
13
+ Replace standard ` /bin/sh ` with ` sh ` file produce by running ` make build `
14
+
15
+ [ Relevant discussion] ( https://github.com/aws/amazon-ssm-agent/pull/171 )
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "log"
5
+ "os"
6
+ "os/exec"
7
+ )
8
+
9
+ func main () {
10
+ _ , set := os .LookupEnv ("GO_SH_WRAPPER" )
11
+ if set {
12
+ os .Exit (0 )
13
+ }
14
+ env := append (os .Environ (),"GO_SH_WRAPPER=1" )
15
+ args := os .Args [1 :]
16
+ cmd := exec .Command ("/bin/bash" , args ... )
17
+ cmd .Env = env
18
+ cmd .Stderr = os .Stderr
19
+ cmd .Stdin = os .Stdin
20
+ cmd .Stdout = os .Stdout
21
+ if err := cmd .Run (); err != nil {
22
+ log .Fatal (err )
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments