The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
Want to understand the meaning of the following line
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
Want to understand the meaning of the following line
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
3
(
permalink
)
05-24-2007
blowtorch
Supporter
Join Date: Dec 2004
Location: Singapore
Posts: 2,350
What shell are you using for this? I tried this with sh, ksh and bash, and it worked with all three. I had to make one modification though:
Code:
#!/usr/bin/bash echo "Hello World" . ./test_common.lib get_info
Without the "./" it was giving a "./test.sh: test_common.lib: not found" error under sh and ksh.
As for the explanation of how the ". test_common.lib" line works, here's how:
When you run . test_common.lib, or in my case . ./test_common.lib, the statements in the test_common.lib file are processed inside the calling shell itself, unlike when you just run ./test_common.lib (this forks a seperate process). Because the calling shell processes these, any statements such as variable definitions, function definitions, etc are stored in the calling shell and are available for later use.
Hope that was clear (though it probably isn't).
blowtorch
View Public Profile
Find all posts by blowtorch
Find blowtorch's past nominations received
Find blowtorch's present nominations given