Find the answer to your Linux question:
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.
  1. #1
    Just 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

  2. #2
    Just Joined! wildpossum's Avatar
    Join Date
    Apr 2008
    Location
    Sydney/Australia
    Posts
    92
    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
    ~>

  3. #3
    Just 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!

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by PopyCaste View Post
    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.
    Right.

    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..
    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.

    My question is, how can I change it?
    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.

    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.

    And why this could be a working sample .bashrc-file when obviously the environment variables - that are used - are not initialized by default.
    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).

    When I export the two variables, they won't be there after rebooting, right?

    Best regards!
    Right. But you could export them at the very beginning of the script. Not that it would make much sense, though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •