All Questions
Tagged with quoting environment-variables
6
questions
217
votes
3
answers
105k
views
$VAR vs ${VAR} and to quote or not to quote
I can write
VAR=$VAR1
VAR=${VAR1}
VAR="$VAR1"
VAR="${VAR1}"
the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?
25
votes
2
answers
12k
views
Expansion of a shell variable and effect of glob and split on it
This post actually contains two separate questions but I think grouping them together will give some more context. I have gone through this question on quotes around variables but I do not quite ...
38
votes
2
answers
51k
views
What is the significance of single and double quotes in environment variables?
I defined some environment variables in my .profile like this:
MY_HOME="/home/my_user"
but the variable does not seem to evaluate unless I strip off the quotes and re-source the file. I believe the ...
3
votes
1
answer
370
views
Why does this variable have no value even though it is set in .bashrc?
If I append this:
hi=11
export hi
to the .bashrc and then I su to this user with:
su - bela
then I:
echo $hi
11
Then it's working, the "hi" variable has the value of "11". But. When I:
su -...
2
votes
2
answers
734
views
Meaning of \ before environment variable
In ksh on an old Solaris box I used:
export PS1="$PWD $"
to set the prompt to the current directory. It works great until you cd elsewhere, then you see that it's not evaluating PWD each time. I ...
1
vote
2
answers
6k
views
Why is this environment variable not set up?
When a shell runs an external executable as a command, we can pass
environment variables into the executable.
$ var=3 /bin/echo `$var`
$ var=3 bash -c "/bin/echo '$var'"
both don't output anything.
...