List Info

Thread: perl "system" command / trouble with path env variable




perl "system" command / trouble with path env variable
user name
2007-10-19 15:25:28
# New Ticket Created by  JimWoodworth 
# Please include the string:  [perl #46557]
# in the subject line of all future correspondence about
this issue. 
# <URL: h
ttp://rt.perl.org/rt3/Ticket/Display.html?id=46557 >


Hello,
   
  I am running perl 5.8.7 in a unix environment.  I found
that perl's system command seems to discard any portion of
the PATH environment variable containing a tilde pointing to
a person's home directory.
   
  if a command of the same name exists in both
"~mf" and "another", it will pick up the
command out of "another".
  ~mf:another:rest_of_the_path
   
  however, if the path is set to
  /home/mf:another:rest_of_the_path
  then, the command in "/home/mf" is picked up
instead.
   
  Regards,
  James Woodworth
   

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 
Re: perl "system" command / trouble with path env variable
user name
2007-10-19 17:01:30
JimWoodworth wrote:
>I am running perl 5.8.7 in a unix environment.  I found
that perl's
>system command seems to discard any portion of the PATH
environment
>variable containing a tilde pointing to a person's home
directory.

Tildes don't have that meaning in PATH.  Tildes referring to
home
directories is purely a shell feature, not an inherent part
of Unix.
If you want to put your home directory in the PATH then you
need to get
the tilde expanded first.  Some shells will help you with
that, like this:

zsh% echo ~
/home/zefram
zsh% foo=aoeu:~
zsh% echo $foo
aoeu:/home/zefram

But ~ is not generally a metacharacter when it's not at the
start of
a word:

zsh% echo aoeu:~
aoeu:~

and some shells won't do the magic
expansion-after-colon-in-variable.
In that case, say "$HOME" instead of
"~", because any shell will expand
"$HOME" anywhere in a word:

zsh% echo aoeu:$HOME
aoeu:/home/zefram

Note that the literal characters "$HOME" are no
more useful in PATH than
"~" is.  You need to get the actual
"/"-delimited pathname into PATH,
and "~" and "$HOME" are merely ways of
referring to that pathname in
the shell.

-zefram

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )