sh[it] and What am I missing here?

Baho Utot baho-utot at columbus.rr.com
Mon Jun 6 09:27:41 UTC 2016


On 06/05/16 22:20, Kevin P. Neal wrote:
> On Sun, Jun 05, 2016 at 01:49:32PM -0400, Baho Utot wrote:
>> On 06/05/16 13:40, Ernie Luzar wrote:
>>> Place your script in /usr/local/bin on your development pc and on the
>>> new installed os pc. Then just entering the script on the console
>>> command line will cause it to execute.  BY the way your script doesn't
>>> need to be suffixed with .sh to work.
>> It does need the suffix .sh because if it is missing I fail to
>> function...... the computer does just fine.
> No, if this is the case you are doing something weird. The filename does
> not matter, and the extension is just part of that filename.
>
> A shell script should start with the "#!" line (the "shebang" line) as the
> very first line, and it should have the executable bits set. It will then
> run with the interpreter specified in the initial shebang line. That is,
> when run from a command line. And it must be either in your path or have
> the path to it specified (like the "./" prefix mentioned earlier in the
> thread assuming the script is in the current directory).
>
> If you run a shell script by giving it as an argument to an invocation of
> a shell command then you are bypassing both the shebang line and the
> executable bits. This will tend to give surprising results. Don't do that.
>
Are you saying the following is bad?

sh my.fault

I always use this layout

cat my.fault.sh

#!/bin/sh
#    Do a bunch of stupid things
.....
# Then try to figure out what happened
....
printf "%s\n" "Run Complete"

BTW are you Cowboy Neal?



More information about the freebsd-questions mailing list