From: Aftermath Fan on
I am stuck working in ksh 1988 (thank you HP-UX). Here is the
behavior I am observing - is this expected?

lib.sh: has a function ( "blah()")

top_script.sh: sources lib.sh and can call blah() and it works just
fine

top_script.sh executes bottom_script.sh. In bottom_script.sh, blah()
is not found

Variables propagate through export but functions apparently don't, and
even putting "export blah" doesn't seem to do anything.



From: Ben Bacarisse on
Aftermath Fan <survivalist(a)gmail.com> writes:

> I am stuck working in ksh 1988 (thank you HP-UX). Here is the
> behavior I am observing - is this expected?
>
> lib.sh: has a function ( "blah()")
>
> top_script.sh: sources lib.sh and can call blah() and it works just
> fine
>
> top_script.sh executes bottom_script.sh. In bottom_script.sh, blah()
> is not found
>
> Variables propagate through export but functions apparently don't, and
> even putting "export blah" doesn't seem to do anything.

That's what most (all?) shells do -- I don't think you can lay that at
ksh's door. Can't you have top_script.sh source (rather than execute)
bottom_script.sh or have bottom_script.sh source lib.sh?

--
Ben.
From: Chris F.A. Johnson on
On 2010-03-08, Ben Bacarisse wrote:
> Aftermath Fan <survivalist(a)gmail.com> writes:
>
>> I am stuck working in ksh 1988 (thank you HP-UX).

Download and compile bash.

>> Here is the
>> behavior I am observing - is this expected?
>>
>> lib.sh: has a function ( "blah()")
>>
>> top_script.sh: sources lib.sh and can call blah() and it works just
>> fine
>>
>> top_script.sh executes bottom_script.sh. In bottom_script.sh, blah()
>> is not found
>>
>> Variables propagate through export but functions apparently don't, and
>> even putting "export blah" doesn't seem to do anything.
>
> That's what most (all?) shells do -- I don't think you can lay that at
> ksh's door. Can't you have top_script.sh source (rather than execute)
> bottom_script.sh or have bottom_script.sh source lib.sh?

Functions can be exported in bash (export -f name).


--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====
From: Dominic Fandrey on
On 08/03/2010 01:20, Aftermath Fan wrote:
> I am stuck working in ksh 1988 (thank you HP-UX). Here is the
> behavior I am observing - is this expected?
>
> lib.sh: has a function ( "blah()")
>
> top_script.sh: sources lib.sh and can call blah() and it works just
> fine
>
> top_script.sh executes bottom_script.sh. In bottom_script.sh, blah()
> is not found

Is there any reason you do not source bottom_script.sh?

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?