Arijit Das wrote:

> Hi,
> 
> The format of env variable PATH seems to change with
> OS/shell. For example, 
> in sh it is like 
> 
> "/dir1/bin:/dir2/bin:."
> 
> while in csh, it is like 
> 
> (/dir1/bin /dir2/bin .)
> 
> I need to search for "/dir2/bin" path component in my
> $ENV{PATH}, and then, insert "/newpath/bin" just
> before "/dir2/bin". But due to different format of
> PATHs in different os/shells, I am not able to do that
> in a very clean way.
> 
> Is there any Perl Array (somewhat like @INC) which I
> can modify to have my PATH changed?

You're only modifying it for any child processes you create,
so you could force the children to be spawned by one sh or
the other (tcsh/bash) or you could find the user's shell in
the /etc/passwd entry and use that one.

if ($shell =~ /^(?:ba)?sh$/) {
} elsif ...

You could check the existing PATH vrbl and see if it's sh/bash or
csh/tcsh style path (' ' vs ':') and go accordingly.

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to