Re: text/html; mutt_bgrun mozilla.sh %s; test=InXTerm
On Thu, Nov 03, 2005 at 03:09:04PM -0500, Kyle Wheeler wrote:
> Wow - talk about an amusing script.
>
> So, the point of the above script is to have a return value of either 0
> or 1 depending on whether $TERM is "xterm" or not. To find out whether
> $TERM is "xterm" or not, it uses a program called "test" (which is also
> known as [ -- check it out, it's /bin/[ on your system).
FWIW, while there definitely is a /usr/bin/[ (that's where it is on my
system), as well as a /usr/bin/test, in bash this is a builtin. And,
while quite similar, the semantics between the two are different.
Not that this changes what you're saying at all... ;-)
> Now, let's think about something else: why test to see if you're in an
> xterm or not?
This is a perfectly valid question. Another problem is, even if you
ARE running in an xterm, that doesn't necessarily mean you can run X
clients on the local machine. Your xterm may be on your local
display, whereas you may be reading mail in mutt remotely on a server
which has no X window system even installed...
> What you're really looking for is you're looking to see if you're
> running in an environment where mozilla (or in the example case above,
> "display") can be run: i.e. you don't want it to run if you're in a
> terminal where an X11 server isn't available. I mean, if you're running
> an xterm, then X11 is available
As I just demonstrated, not necessarily. ;-)
> The DISPLAY variable is more powerful and more accurate: if it
> exists, you should be using a terminal where an X11 server is
> available. If it doesn't exist, you are using a terminal where an
> X11 server is not available.
Better still, define and use your own environment variable expressly
for this purpose. Even if DISPLAY is set, you may not want to launch
your web browser... An example would be if you're logged in remotely
over 300 bps modem. :) I think I even still have one of those in a box
somewhere...
--
Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address. Replying to it will result in
undeliverable mail. Sorry for the inconvenience. Thank the spammers.