okta / okta-aws-cli

A CLI for having Okta as the IdP for AWS CLI operations
https://github.com/okta/okta-aws-cli
Other
128 stars 34 forks source link

Garbage printed when using xdg-open #91

Closed perj closed 1 year ago

perj commented 1 year ago

On Linux, when using eval $(okta-aws-cli -b), I assume -b flag makes the tool exec xdg-open. Unfortunately, the output of that command is piped to stdout and become part of the string passed to eval.

For example, on my laptop it prints

Öppnas i en befintlig webbläsarsession.

which causes the error

Öppnas: command not found

The string is printed asynchronously, after xdg-open exits. Presumably it's piped from Chrome somehow, based on the output.

monde commented 1 year ago

Seems to be coming from Brave. https://fossies.org/linux/brave-core/app/resources/generated_resources_sv.xtb

Unfortunately, we can't control what 3rd party tools print to STDOUT when capturing the STDOUT from okta-aws-cli with an eval. I'm not certain to xde-open alternatives. However, we are using pkg/browser for popping the browser and I found this comment on the linux driver:

https://github.com/pkg/browser/blob/99a9298f083b488debce97664d7d7530fe6d5c79/browser_linux.go#L11-L13

// There are multiple possible providers to open a browser on linux
// One of them is xdg-open, another is x-www-browser, then there's www-browser, etc.
// Look for one that exists and run it

Perhaps x-www-browser or www-browser will help, or using a different browser.

perj commented 1 year ago

It's possible to set where the stdout of the command goes here: https://github.com/pkg/browser/blob/681adbf594b8314eb76d83a271f4a1c152d057d9/browser.go#L16

monde commented 1 year ago

@perj I'll slip this in on the next release, nice find.