I constructed a command like this in a bash script
a="my_cmd";
a="$a --verbose";
echo $a;
$a;
It works and executes my command correctly. But when I add an environment variable to the mix it breaks.
a="my_cmd";
a="URL=myurl $a --verbose";
echo $a;
$a;
It breaks at "URL=myurl" saying No such file or directory, but if I run it using eval() the command works correctly.
a="my_cmd";
a="URL=myurl $a --verbose";
echo $a;
eval "$a";
Can someone kindly explain why adding environment variable to the mix broke my command in second example.
Aucun commentaire:
Enregistrer un commentaire