I'm looking at 2 files that were written by someone else, and I'm not understanding the syntax. foo.sh
calls bar.sh
foo.sh
#!/bin/bash
. /ABSOLUTE/PATH/TO/FILE/bar.sh hello
bar.sh
echo bar: $1 $2
The stdout from running foo.sh is bar: hello
The primary confusion is why does the line . /ABSOLUTE/PATH/TO/FILE/bar.sh hello
start with a .
(Note the space, this is not a relative path, but an absolute path). It seems I can call bar.sh
with or without the .
and it seems to work (Note there is no #!/bin/bash
in bar.sh
)
My secondary confusion is that bar.sh
seems to be referencing 2 parameters $1
and $2
, but seems like only one parameter is being passed in. This is code that I believe is running, and relies on $2
being valid (but I don't know what the value is).