granted icon indicating copy to clipboard operation
granted copied to clipboard

fix assume script not printing output properly on linux

Open chrnorm opened this issue 2 years ago • 1 comments

Fixes #255.

Sometimes Granted needs to print to stdout. Our assume wrapper script needs to capture Granted's output in a specific format, so we prepend anything that needs to be printed with GrantedOutput. assume then chops the GrantedOutput prefix off and prints the rest to stdout.

For running commands like assume my-profile --exec "echo hello world", the output that the assumego Go binary creates is:

GrantedOutput
hello world

Which is then interpreted by the assume wrapper, and finally printed to the console as

hello world

the problem

Bash on Ubuntu was printing

GrantedOutput <URL>

Whereas the assume script requires the output to look like

GrantedOutput
<URL>

with a newline in between.

chrnorm avatar Sep 21 '22 15:09 chrnorm

Confirming that this resolves the reported issue. Nice work!

QuinnyPig avatar Sep 21 '22 15:09 QuinnyPig

shellcheck is often good at finding these kinds of issues. It's basically static analysis linter for shell scripts. I often run it in CI and let it pass/fail the PR.

lorengordon avatar Sep 24 '22 15:09 lorengordon

Fantastic suggestion @lorengordon, I've added support for shellcheck in our CI in #265. Shellcheck correctly caught the issue in #255 too.

chrnorm avatar Sep 26 '22 10:09 chrnorm