I have worked all my life in HPUX/ksh shell, so bash these days seems to be throwing new ways of doing many things (many of which don't seem to be POSIX compliant - for example 'mkdir -p /root/{abc,def,ghi,jkl}' - apparently this is a coding guideline best-practice in bash / OpenStack - but that's a different rant altogether).
Anyways, I have been seeing this sort of script execution in multiple places in OpenStack code:
ENABLE_VCENTER=true bash /root/stack_install.sh
Can someone explain how this works - I know that the shell will set the variable and then invoke the shell script (which is the explanation the classic nooB mistake for why variable assignment shouldn't be with spaces - eg. HELLO= world). But what exactly happens internally?
Also, why doesn't it seem to work for me when I try this command:
HELLO=world echo $HELLO
I get the following output from the shell:
[ ubuntuOne : /home/bumblebee ]
> HELLO=world echo $HELLO
[ ubuntuOne : /home/bumblebee ]
>
What am I missing here?
Thanks for your replies.