Operating System - HP-UX
1748250 Members
3626 Online
108760 Solutions
New Discussion юеВ

fpath and null entry in $PATH

 
Steve Cameron_1
New Member

fpath and null entry in $PATH

When I set FPATH to a single directory and ${PATH} contains a null entry (a leading colon) and I'm in the directory specified in FPATH, it looks like my function doesn't get executed.

Is this expected or have I misunderstood?

/tmp/fpath>cat Called
#!/bin/sh -u
Called ( ) {
echo "In called"
return 0
}

/tmp/fpath>cat Main
#!/bin/sh -u
echo "current PATH=${PATH}"
FPATH=/tmp/fpath
Called

/tmp/fpath>./Main
current PATH=/usr/bin:/usr/sbin
In called

/tmp/fpath>export PATH=/tmp:${PATH}
/tmp/fpath>./Main
current PATH=/tmp:/usr/bin:/usr/sbin
In called
/tmp/fpath>cd ..
/tmp>fpath/Main
current PATH=/tmp:/usr/bin:/usr/sbin
In called
/tmp>cd fpath

/tmp/fpath>export PATH=:${PATH}
/tmp/fpath>./Main
current PATH=:/tmp:/usr/bin:/usr/sbin
/tmp/fpath>cd ..
/tmp>fpath/Main
current PATH=:/tmp:/usr/bin:/usr/sbin
In called
2 REPLIES 2
renarios
Trusted Contributor

Re: fpath and null entry in $PATH

Hi Steve,

Looks OK to me!
What do you want to accomplish?
Maybe this link helps: http://www.unix.org.ua/orelly/unix/ksh/ch10_02.htm

Hope it helps,

Renarios
Nothing is more successfull as failure
Cesare Salvioni
Trusted Contributor

Re: fpath and null entry in $PATH

Hi

i'm not sure, but seems to me that the problem comes from a null path in PATH variable acting as a . (dot), the current directory.

I mean that if you have /tmp/fpath in your PATH environment the file /tpm/fpath/Called is executed when you call the function Called. In this way the function is never executed.

Using the FPATH variable from the autoload function mechanism of the shell means, instead, do the sourcing of the file Called and exec the function Called

Hope this helps