[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird problem -- path interpretted/eval'd as numeric expression

From: Stefano Lattarini
Subject: Re: weird problem -- path interpretted/eval'd as numeric expression
Date: Fri, 29 Mar 2013 14:19:48 +0100

On 03/29/2013 12:57 PM, Greg Wooledge wrote:
> On Fri, Mar 29, 2013 at 12:41:46AM -0700, Linda Walsh wrote:
>>      include was designed to search the path for functions that
>> are relative paths.  While the normal sourcepath allows searching for
>> filenames on the search path, I don't believe (please correct if I am wrong
>> and this works now, as it would make life much simpler) that the PATH will
>> be searched if you give it something like:
>> source lib/Util/sourcefile.shh
> Is that all you want?  Here:
> include() {
>     local paths dir
>     IFS=: read -ra paths <<< "$PATH"
>     for dir in "address@hidden"; do
>       if [[ -r $dir/$1 ]]; then
>           source "$dir/$1"
>           return
>       fi
>     done
>     echo "could not find '$1' in PATH" >&2
>     return 1
> }
AFAIK, this won't work if the sourced file contains declarations
like 'declare -a foo=(1 2)'; those variables will be made local to
the 'include' function.  Perhaps an alias could work better (but
writing it might involve some unpleasant tricks with eval etc.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]