ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yeah - forget the loop.
I though maybe that this would open up the program in an independend shell, and each loop gets send to antoher shell.
that is not it though.
What does the . mean in bash.
In perl it means a concatination - and I though that is what is was doing here - concatatining this directory to executable path.
but it is not.
And when I look up period bash in google I get nothing
What is the period in bash mean (it is not a regular epressions either)
In this case "." is the source command. There is no need to do anything special for concatenation in the shell. Just stick things together. The PATH setting command you asked about is doing just that.
See here for a fairly-complete list of all specially-treated characters in bash:
Looks like there is/was an optional _env.sh script in each directory with shellscript files. If _env.sh exists it would work like a shell "library", from the name probably used to configure the shell/scripting environment and/or set environment variables.
BTW the ";" at the end of export PATH="`dirname "$0"`:$PATH"; terminates the first command so the whole line is functionally equivalent to (and more obscure than):
Code:
export PATH="`dirname "$0"`:$PATH"
. _env.sh
Last edited by catkin; 05-25-2012 at 10:57 AM.
Reason: clarity
Hmm, but a source doesn't use $PATH. "_env.sh" will always be in the current directory. I'd be more given to think it was to maybe override system programs? a copy of ls in the current directory woul be used in preference to /bin/ls
Hmm, but a source doesn't use $PATH. "_env.sh" will always be in the current directory.
Nope, source does use path:
Code:
~$ help .
.: . filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
to source another script from the same directory as the original script when writing widely compatible Bourne shell/POSIX shell scripts that cannot rely on being installed in a specific directory. Note that if you do not need to be compatible with ancient versions of /bin/sh, it is better to use BASE="$(dirname "$0")"
Note that sourcing another file means the other file is essentially "included", executed using the same shell instance. In particular, all variables and functions set by the other file will be available to the original script too. This is often used for setting configuration values, so that they only need to be updated in one file only. For an example, look at your service scripts in /etc/init.d/. (Note however that they source their files using fixed paths.)
Although you often see the test flag using -e (exists) or -x (is executable), the -r (is readable) is more appropriate. You do not need execute rights to source a file, only read rights.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.