Added check for config file presence

This commit is contained in:
Andrea Mistrali 2021-12-03 15:22:17 +01:00
parent c2f1f88766
commit 3dd3bd61c3
No known key found for this signature in database
GPG Key ID: 6FB0A77F6D5DA9B2
2 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,10 @@
profile=$1 profile=$1
if [ ! -f ~/.aws/config ]; then
echo "no aws config file found, bailing out..."
return 1
fi
if [ $profile ]; then # We got a profile pattern, look for a match if [ $profile ]; then # We got a profile pattern, look for a match
match=$(grep -E "\[profile .*$profile.*" ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/') # Array of matching profiles match=$(grep -E "\[profile .*$profile.*" ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/') # Array of matching profiles
match_no=$(echo $match|wc -l) # Number of profile matching match_no=$(echo $match|wc -l) # Number of profile matching

Binary file not shown.