We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Bash: Nested functions and including other scripts

Hello.

I have the following problem with bash code:

function fl1_load_modules_and_get_list()
...........
	for module in $FL_MODULES_TO_PROCESS
	do
		source "${FL_MODULE_DIR}/${module}/module.sh"
	done
...........
}

function fl1_handle_install
{
	local FL_MODULES_TO_INSTALL=$(fl1_load_modules_and_get_list $1)
	
	#Executing pre-install routines
	for module in $FL_MODULES_TO_INSTALL
	do
		fl_mod_${module}_pre_install
	done
}

First function is called inside the second one. First function loads scripts in which functions with predefined names reside. The second function calls the first and then attempts to call functions with names, that must be loaded with first one.
Loading files with source seem to complete successfully because I have

set -o errexit
set -o nounset
set -o pipefail

at the main script.

But when fl_mod_${module}_pre_install call is done, I can see a message like /usr/local/fractal/fl/lib/handle_install.sh: line 8: fl_mod_php_pre_install: command not found
Somehow functions loaded by the first function are not imported into the global scope... Any idea why?

Thanks.

I have forgotten to add. In the attachment is the source code I play with. Execute

f-linsey install all

And the error I was talking about appears.

Thank you

Attachments f-linsey.zip (4.77KB)
1
Contributor
0
Replies
1
View
FractalizeR
Newbie Poster
3 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0609 seconds using 2.65MB