1

I submitting some computations to the cluster and found out, that if I run my shell script that has qsub in it with . (note the space after the dot) instead of ./ the scope of some variable change and I don't have problems with library access, as I have with ./.

I know there have been questions about it before. 1 2

They discuss sh and . ./ method, however, and don't touch on .

Is . the same thing as . ./?

Community
  • 1
  • 1
neuronich
  • 135
  • 1
  • 8
  • 1
    `./` is just part of the path to the script, it has nothing to do with the way the script is run. – Barmar Dec 31 '13 at 03:34
  • 1
    I don't understand why you say that the questions you linked to don't touch on your question. They both do. – Barmar Dec 31 '13 at 03:35
  • `.` is a shell command (it's another name for `source`). `./` is just part of the filename. `. ./whatever` is always redundant, because `source` will look in the current directory anyway. – hobbs Dec 31 '13 at 03:38

2 Answers2

3
. cmd

vs

./cmd

are night and day different.

The first, is more like an "include", it executes the cmd within the context of the currently executing shell.

The second, is a path operation. ./cmd is akin to /usr/local/bin/cmd. the ./ is a path specifier.

In this case, it is saying that you are running a cmd in the current directory, rather than searching the PATH env variable for cmd.

When the cmd is executed, it is forked and exec'd in to it's own process, unrelated to the current process. A completely different result from the first example.

Will Hartung
  • 115,893
  • 19
  • 128
  • 203
1

. is used to source a script. The script will be run in the current shell, and any variables it sets will be available afterwards.

./ is a way of saying the 'current directory', and is just a path reference.

Niall Byrne
  • 2,448
  • 1
  • 17
  • 18