From c2cd6260c5dd375ed320ff1b5fcd79158b4cf38c Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Tue, 24 Nov 2026 15:20:02 -0800 Subject: [PATCH] fix(aws): skip bare config sections like `[plugins]` in `aws_profiles` In ~/.aws/config, only `[default]` and `[profile foo]` name profiles. Bare sections such as `[plugins]` were listed and accepted by `asp`, although the AWS CLI cannot use them. Bare `[foo]` sections still count in the credentials file. --- plugins/aws/aws.plugin.zsh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 1c6c83f1f..de3c9f04c 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -247,17 +247,20 @@ function aws_profiles() { aws --no-cli-pager configure list-profiles 2> /dev/null return fi - local line words - # Only read the section headers, so the credentials never enter the shell - for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do - line=${line#*\[} # drop up to the first [ - line=${line%\]*} # drop from the last ] (comments, CR) - words=(${=line}) - if (( $#words == 1 )); then - print -r -- $words[1] # [default], or [foo] in the credentials file - elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then - print -r -- $words[2] - fi + local file line words + for file in "$config" "$creds"; do + # Only read the section headers, so the credentials never enter the shell + for line in "${(@f)$(command grep '^[[:space:]]*\[' -- "$file" 2> /dev/null)}"; do + line=${line#*\[} # drop up to the first [ + line=${line%\]*} # drop from the last ] (comments, CR) + words=(${=line}) + if (( $#words == 1 )); then + # [default], or any [foo] in the credentials file + [[ $file == $creds || $words[1] == default ]] && print -r -- $words[1] + elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then + print -r -- $words[2] + fi + done done | command sort -u }