Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Environment discovery under Linux

by rovf (Priest)
on Sep 30, 2008 at 08:06 UTC ( [id://714501]=note: print w/replies, xml ) Need Help??


in reply to Environment discovery under Linux

You do not need to run env externally, because the whole environment is already available in the hash %ENV. There is, however, another flaw in your solution: bash does NOT guarantee that SHELL is set at all.

I don't think there is a foolproof way to find out which shell you have. One possibility to test for bash would be with the following command:

perl -wle '@ARGV==0 && print "warning, you are not running bash"' $BAS +H_VERSION
We can't use %ENV here, because BASH_VERSION is not an environment variable.

Another possibility is to use the current process id ($$) and the output of ps and see how the current process was called, assuming that if it is something like 'bash' or '-bash', it is probably a bash shell.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^2: Environment discovery under Linux
by The Hindmost (Scribe) on Sep 30, 2008 at 08:30 UTC
    I feel very foolish for not remembering that;
    (I suppose it's what you get for getting an idea on a Uni pub crawl scrawling it on a beer mat and trying to code it up when you get in still drunk; oh well)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://714501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (None)
    As of 2024-04-19 00:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found