From d941cd0b527ed1f5885d6ab7fcfb9030736f5491 Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Tue, 4 Apr 2023 11:07:00 +0200 Subject: [PATCH 1/2] docs: fix bashrc snippet --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a5f14c..bccc2d9 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ By default, the utility prints out the `export` statements for the credentials ( ```bash aws-sso-cli() { - command aws-sso-cli "$@" | while read -r line; do + while read -r line; do if [[ $line =~ ^export ]]; then eval $line fi - done + done < <(command aws-sso-cli "$@") } ``` From a6d6ea73068c245003862dc7fd01213a7fbd0e63 Mon Sep 17 00:00:00 2001 From: Pelle Johnsen Date: Wed, 14 Jun 2023 08:10:56 +0000 Subject: [PATCH 2/2] fix: make .bashrc snippet also work for .zshrc --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bccc2d9..bc6ab56 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,14 @@ By default, the utility prints out the `export` statements for the credentials ( ```bash aws-sso-cli() { - while read -r line; do - if [[ $line =~ ^export ]]; then - eval $line + local tmp_file=$(mktemp) + command aws-sso-cli "$@" > "$tmp_file" + while IFS= read -r line; do + if [[ "$line" =~ 'export AWS_' ]]; then + eval "$line" fi - done < <(command aws-sso-cli "$@") + done < "$tmp_file" + rm "$tmp_file" } ```