Results 1 to 4 of 4
Hello
I wonder why my $HOST and $DISPLAY environment variables are empty. I downloaded a sample .bashrc and it says when spawning a new shell with 'su':
bash: HOST: unbound ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-27-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 3
no $HOST and $DISPLAY variable?
Hello

I wonder why my $HOST and $DISPLAY environment variables are empty. I downloaded a sample .bashrc and it says when spawning a new shell with 'su':
bash: HOST: unbound variable
bash: HILIT: unbound variable
Do you know what I can do to solve this problem?
Best regards,
Phil
- 04-28-2008 #2
If your running as a terminal session outside of X then you would expect that $DISPLAY may not be set. If your doing "echo $DISPLAY" within a Xterm under X then you can and would expect the variable to be set to something like ":0".
You haven't explained if and why this should be a problem!
I suspect, if your just playing around to understand the inner workings of shell variables that your simply forgot to export the variable. i.e.:
~>
~> export HELLO='yes OK'
~> echo $HELLO
yes OK
~>
- 04-28-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 3
I want to customize this sample .bashrc file http://tldp.org/LDP/abs/html/sample-bashrc.html. But it doesn't work, because the two mentioned environment variables aren't set by default.
Please have a look on the link above and search for "DISPLAY" in it, for example. The author uses if-clauses to determine, on which system we are, using the DISPLAY-variable, doesn't he?
But as you say, normally the variable is not set by default and as a result, i get one error message on every command i enter on the shell..
My question is, how can I change it? And why this could be a working sample .bashrc-file when obviously the environment variables - that are used - are not initialized by default.
When I export the two variables, they won't be there after rebooting, right?
Best regards!
- 04-28-2008 #4Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Right.
Well, the author might be one of those that never operate outside X, that's why s/he probably didn't notice this problem. However, it's a very obvious error.Please have a look on the link above and search for "DISPLAY" in it, for example. The author uses if-clauses to determine, on which system we are, using the DISPLAY-variable, doesn't he?
But as you say, normally the variable is not set by default and as a result, i get one error message on every command i enter on the shell..
You could check if $HOST is set, and if it's not set, set it to a default value. I don't know the purpose of that value, so I can't figure out what would be a good default value.My question is, how can I change it?
Note also that that script loads by default /etc/bashrc, while some distros often use /etc/bash/bashrc.
I don't have the time to review the whole rc file right now, and it just seems to me way too complicated, just to get fancy useless stuff in your prompt. It's about tastes, though.
I don't know. It seems that this rc file is not too well tested, and it's also old (though that shouldn't matter).And why this could be a working sample .bashrc-file when obviously the environment variables - that are used - are not initialized by default.
Right. But you could export them at the very beginning of the script. Not that it would make much sense, though.When I export the two variables, they won't be there after rebooting, right?
Best regards!


Reply With Quote

