Not able to reference softlinks in a script

0

we have couple of softlinks to scripts a directory in our current directory. Let's take we have two softlinks , script1 and script2. We are referencing script2 from within a script1 like below.

. script2

It was running fine until we changed our infrastructure. Now, if we trigger the softlink script1 it's not able to find the softlink script2 in it and throws error. Though it works if we change the softlink reference in script1 like below.

. ./script2

Any obvious reason for that.

Ahmad

Posted 2014-03-17T18:11:12.923

Reputation: 199

Answers

1

As the bash manpage explains, source (which . is a shorthand for), searches the file in $PATH if it does not contain a /, thus

. script1

is just wrong and your issue has nothing to do with symbolic links, but it's more an issue of versions of bash (this behavior changed at some point in time, IIRC). At least zsh and dash (which is a rather compliant POSIX-shell) do this the same.

Andreas Wiese

Posted 2014-03-17T18:11:12.923

Reputation: 1 911