Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Re: UNIX environment setup via perl

by haoess (Curate)
on May 07, 2004 at 16:22 UTC ( #351511=note: print w/replies, xml ) Need Help??

in reply to Re: UNIX environment setup via perl
in thread UNIX environment setup via perl

> You should check for $ENV{SHELL} and emit "setenv VAR VALUE"
> lines if appropriate.

$ENV{SHELL} is not a way to determine your current shell. $ENV{SHELL} is your »preferred shell« (aka login shell in /etc/passwd), see The Single UNIX Specification, Version 3.


# we are in bash, all is fine $ eval `perl -le 'print $ENV{SHELL} =~ /csh/ ? "setenv FOO bar" : "exp +ort FOO=bar"'` # now we switch to tcsh $ tcsh $ eval `perl -le 'print $ENV{SHELL} =~ /csh/ ? "setenv FOO bar" : "exp +ort FOO=bar"'` $ export: Command not found. $ echo $SHELL /bin/bash

It seems that there is no portable way to find out the name of your current shell. We discussed that some time ago at

Replies are listed 'Best First'.
Re: Re: Re: UNIX environment setup via perl
by eserte (Deacon) on May 07, 2004 at 17:24 UTC
    Looking at $ENV{SHELL} is probably the best we can do --- other programs seem to do it the same way (and therefore do it wrong):
    $ env SHELL=/bin/sh ssh-agent SSH_AUTH_SOCK=/tmp/ssh-XXN54U4g/agent.3950; export SSH_AUTH_SOCK; SSH_AGENT_PID=3951; export SSH_AGENT_PID; echo Agent pid 3951;
    $ env SHELL=/bin/tcsh ssh-agent setenv SSH_AUTH_SOCK /tmp/ssh-XXPC7hgb/agent.3948; setenv SSH_AGENT_PID 3949; echo Agent pid 3949;
    Similar output for /usr/X11/bin/resize

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://351511]
[ambrus]: erix: that one actually sucks. these days people should get rid of the old notion that TeX is the only thing you can use for decent mathematics writing, because MS Office and LibreOffice have reached the
[ambrus]: level where people can more easily write as good mathematical papers in them as the people who write bad LaTeX papers usually write.
[ambrus]: Yes, for like the first twenty of its years, TeX was basically the only system that allowed you to write decent maths papers, and C++ and PHP were programming languages that sucked, etc. But times change and people have to accept that.
Discipulus bad people + good tool < normal people + decent tool
[Discipulus]: php does not suck anymore?
[ambrus]: Discipulus: I'm not sure, but it certainly doesn't suck as much as it's used to. it's like C++, it sucks because people still recursively learn from twenty year old PHP examples,
[ambrus]: and they try to use the obsolete features that PHP has to support only for compatibility with old scripts. C++ and PHP both have the problem that people can't forget the past, because when they google "PHP" plus the problme they want to solve, they find b
[ambrus]: ad code examples.
[ambrus]: I'm not trying to recommend PHP, but I think it has way too bad a name because of its past.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-09-26 11:06 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.