This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shell script ignores $PATH?!


luke.kendall@cisra.canon.com.au wrote:

> So my guess is that when a script with no #!/path line is run, then the
> default is to run /usr/bin/sh to start it, and the PATH simply doesn't
> come into it.

If you want to specify what shell is used to run a script you either
need to specify it in the shebang of the script (#!/path/to/shell) or
you need to start that shell explicitly (/path/to/shell
/path/to/script).  If you try to execute a script with no shebang then
the behavoir is going to be system-dependent.  On cygwin that means
defaulting to /bin/sh, as you can see from spawn.cc:spawn_guts()

      if (buf[0] != '#' || buf[1] != '!')
        {
          pgm = (char *) "/bin/sh";
          arg1 = NULL;
        }

In other words, you were being too ambiguous.  Explicitly call the shell
that you want if it differs from the norm.  The "it'll use whatever is
in the path" is a DOS-ism.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]