Quote:
Originally Posted by
triplemaya
What difference does the shebang make? My scripts have been running ok without it. Does that mean that the system guessed right which interpreter to use?
The system doesn't guess at all -- it assumes /bin/sh if you don't tell it.
Which works great if your script is a garden-variety bourne shell. For Perl, it's wrong.
Quote:
Is it good practice to always put it in?
Yes, especially if you're using shell features like arrays which may not always be present in the garden-variety /bin/sh... /bin/sh may be a full-featured BASH on
your system, but on others it may be a mouldy old shell with no features but pure Bourne.
So use #!/bin/sh for pure bourne scripts, #!/bin/ksh for ksh scripts, #!/bin/bash for bash scripts, and so forth. Use the exact right shell and people will know which it needs. Better they get a 'no such file' error than your script misbehaves and does unintended things.
Quote:
I am calling functions such as mkdir and rsync - does it make a difference if I put in the shebang or not? (I have read man file but I am not a lot wiser on this point as a result.)
These are not functions, they are external programs. As such they don't care at all which shell you use, any shell has access to them and they all run outside it.
Shell builtins on the other hand can vary between shells. /bin/sh may not have pushd/popd, but bash will.