I have a short bash script to take in an int from a user to identify to select a certain eks cluster.
When I use eval $(aws eks --region us-east-1 update-kubeconfig --name eventplatform$input)
I get the error: Updated: command not found
This is resolved if I simply change the command to just aws eks --region us-east-1 update-kubeconfig --name eventplatform$input
Why is the eval command not working for this?
#!/usr/bin/env bash -e
read -p "Which cluster are you trying to access? (int >= 0): " input
while [[ -n ${input//[0-9]/} ]]
do
read -p "Which cluster are you trying to access? (int >= 0): " input
done
eval $(aws eks --region us-east-1 update-kubeconfig --name eventplatform$input)
set -xis your friend to enable trace logging so you can see what's going on. That said, you almost certainly shouldn't be usingevalhere. What's the point of it?set -eis generally a bad idea; it makes your script far harder for readers/reviewers to understand its behavior, not to mention authors. See the exercises section of BashFAQ #105)~/.kube/configfile. It does not output text that can be executed by a shell.eval, there is basically no circumstance whereeval $(something)is more correct thaneval "$(something)"-- the former breaks the output ofsomethinginto words and expands each word as a glob expression before combining them back into a single string and trying to parse that string as code. But collect the xtrace log so we know what's happening during execution before trying to go down that road.