Thursday, February 24, 2005

Variables and bash

I have always wondered this about bash scripting, on IRC:

hello, this is simple, in bash scripting, what is preferred, ${VARI} or $VARI
"$VARI" probably :P
you only need the {} if you've got something after $VARI
I can use $VARI in a string? ABC="kjs;dfksdjfsd $VARI"
you can like that, because there is nothing after it
I see, ABC=${VARI}.zip
however if you did ABC="kjs;dfksdjfsd $VARIabc" that wouldn't work
so you need the {} to tell bash where the variable name ends
ABC="${VARI}.zip" is better in case VARI has spaces in it
ramza2: actually, you can't have . in a variable name. so $ is unambiguous.
ah, once again
it's a matter of taste to some extent, but i would only use {} where absolutely necessary
and then the other way $(VARI) or is that in Make scripts
that's makefiles.


Post a Comment

<< Home