public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: mysterious bash problem
@ 1998-01-16  2:56 Earnie Boyd
  1998-01-17 22:49 ` $Bill Luebkert
  0 siblings, 1 reply; 10+ messages in thread
From: Earnie Boyd @ 1998-01-16  2:56 UTC (permalink / raw)
  To: Ulrich.Lauther; +Cc: gnu-win32

It might help to see foo.  UNIX shell scripts must begin with #! 
/path/to/shelltoexecute.  If you were on UNIX you would then have to set 
the executable bit on the file properties/permissions.  The cygwin.dll 
layer tries to mimick as much of UNIX as it can.  Since the file doesn't 
begin with #! you will not see the executable bit set on the permissions 
as that is how it determines if the file is executable.

I have noticed that the gnu-win32 bash will try to execute the script 
even without the #! indicator.  This is a bug as bash should error 
without this indicator.  For more information see the bash.info file.

>From: Ulrich Lauther <ulrich.lauther@mchp.siemens.de>
>Subject: mysterious bash problem
>To: gnu-win32@cygnus.com
>Date: Tue, 13 Jan 1998 09:31:23 +0100 (MET)
>Reply-To: Ulrich.Lauther@mchp.siemens.de
>
>
>On one NT host where I don't know who fiddled with what happens
>the following:
>
>Let foo be a valid shell script (starting with a ":" in the first line, 
BTW):
>
>bash$ foo
>
>gives:
>
>bash.exe: ./foo: (null)
>
>however,
>
>bash$ bash foo
>
>results in normal execution of the script
>
>this doesn't happen with all scripts, just some.
>
>ls -l gives -rw-r--r-- in all cases
>
>What the hell is going on here?
>-- 
>	-ulrich
>
>----------------------------------------------------------------------------
>Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
>Siemens ZT SE 4         Internet: Ulrich.Lauther@mchp.siemens.de
>-
>For help on using this list (especially unsubscribing), send a message 
to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>


-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------

Check out these great gnu-win32 related sites:
ftp://ftp.cygnus.com/pub/gnu-win32/latest/           (ftp site)
http://www.cygnus.com/pubs/gnupro/                   (Comercial Page)
http://www.cygnus.com/misc/gnu-win32/                (Project Page)
http://www.cygnus.com/ml/gnu-win32                   (Mail Archives)
http://www.itribe.net/virtunix/winhelp-man-pages/    (HTML Man Pages)
http://www.lexa.ru/sos                               (Sergey Okhapkin)
ftp://www.lexa.ru/pub/domestic/sos/                (Sergey's ftp site)
http://www.fu.is.saga-u.ac.jp/~colin/gcc.html        (Colin Peters)
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ (Mumit Khan)
http://gnu-win32.paranoia.ru                   (Chuck Bogorad's ports)
ftp://ftp.deninc.com/pub (Den Internet Services - US mirror and ports)


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
  1998-01-16  2:56 mysterious bash problem Earnie Boyd
@ 1998-01-17 22:49 ` $Bill Luebkert
  0 siblings, 0 replies; 10+ messages in thread
From: $Bill Luebkert @ 1998-01-17 22:49 UTC (permalink / raw)
  To: Earnie Boyd; +Cc: Ulrich.Lauther, gnu-win32

Earnie Boyd wrote:
> 
> It might help to see foo.  UNIX shell scripts must begin with #!
> /path/to/shelltoexecute. 

Not true!

>                           If you were on UNIX you would then have to set
> the executable bit on the file properties/permissions.  

Depends on how you initiate the script.  True if you execute by using 
the script name (eg: "foo.sh" for the script foo.sh).  You could also 
source the script or use it as an argument to the shell.

>                                                         The cygwin.dll
> layer tries to mimick as much of UNIX as it can.  Since the file doesn't
> begin with #! you will not see the executable bit set on the permissions
> as that is how it determines if the file is executable.
> 
> I have noticed that the gnu-win32 bash will try to execute the script
> even without the #! indicator.  This is a bug as bash should error
> without this indicator.  For more information see the bash.info file.

Correct behavior, since the shebang line is not required.

-- 
  ,-/-  __      _  _         $Bill Luebkert
 (_/   /  )    // //       DBE Collectibles
  / ) /--<  o // //      http://www.wgn.net/~dbe/
-/-' /___/_<_</_</_    Mailto:dbe@wgn.net
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
  1998-01-13 10:10 Earnie Boyd
  1998-01-15  7:26 ` Fergus Henderson
@ 1998-01-16  2:56 ` Guy Gascoigne - Piggford
  1 sibling, 0 replies; 10+ messages in thread
From: Guy Gascoigne - Piggford @ 1998-01-16  2:56 UTC (permalink / raw)
  To: Earnie Boyd, Ulrich.Lauther; +Cc: gnu-win32

Well hopefully this will get to the list before umpteen other people have
answered, my mail seems to take forever to turn up on this list :-(

At 06:25 AM 1/13/98 PST, Earnie Boyd wrote:
>>Let foo be a valid shell script (starting with a ":" in the first line, 
>BTW):
>
>To execute a script the first non-blank line must begin with
>#! /bin/sh
>where /bin/sh is the path and shell you want to execute.

That's not completely true.

Whilst putting the #!... as the first line of the script is a good thing,
it's not a requirement. All it does is say, "don't respawn the current
shell to run this script, but spawn this one instead."  If it's not there
then the current shell is used.

If the current shell is used then having a : as the first line is OK since
it's a valid bourne shell command (it evaluates to true among other things
IIRC).  I also remember that this was a standard trick before the #! idea
caught on since it was a harmless way to write scripts that would fail
under csh but run under sh.  So it is valid, but a little old.

Guy


-- 
Guy Gascoigne - Piggford (ggp@informix.com)
Software Engineer, Informix Software, Inc. (Portland, Oregon)

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
@ 1998-01-16  2:56 Earnie Boyd
  0 siblings, 0 replies; 10+ messages in thread
From: Earnie Boyd @ 1998-01-16  2:56 UTC (permalink / raw)
  To: Ulrich.Lauther; +Cc: gnu-win32

>From: Ulrich Lauther <ulrich.lauther@mchp.siemens.de>
>Subject: Re: mysterious bash problem
>To: earnie_boyd@hotmail.com (Earnie Boyd)
>Date: Thu, 15 Jan 1998 16:46:02 +0100 (MET)
>Reply-To: Ulrich.Lauther@mchp.siemens.de
>
>> 
>> Now that I've learned a bit of history, thanks to Fergus Henderson, 
my 
>> best guess is that the file contains line terminators of \r\n.  One 
host 
>> runs the file because it's mounts are text!=binary.  The other 
doesn't 
>> because it's mounts are text=binary.
>> 
>I run it under Unix through dos2unix and it didn't change its size, so 
I guess
>there can't be any \r's.
>I didn't do anything abouts mounts on either host, just installed stock 
>B18 on both.
>If I insert "#! /bin/sh" as first line, it works. That solves my 
problem but not
>my curiosity.
>How do I inspect mounting? Is there a /etc/mtab ? (I am not currently 
at that
>host).

Just simply execute the mount command without any parameters.  The mount 
table is stored in the registry so if your experienced with regedit then 
you could look at it that way.  If you look at the help from mount 
beware that the -b switch is the only one that works properly.  The -m 
switch has be deactivated and the --reset, well it works, but you won't 
like the results.

Speculating again, knowing that you haven't modified anything then you 
are most likely setup for text!=binary which means that the \r is 
expected.  Your file probably worked on the other host because the 
method of transferring the file to the diskette added the \r to the 
file.  Also the editor you are using may be modifying the line 
terminators.  As a test try your dos2unix program again on the modified 
file and see if it still functions.

According to Fergus Henderson and Guy Gascoigne - Piggford the script 
should have worked with your : at the top.  If your not on the list 
check the archives for their responses.



-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------

Check out these great gnu-win32 related sites:
ftp://ftp.cygnus.com/pub/gnu-win32/latest/           (ftp site)
http://www.cygnus.com/pubs/gnupro/                   (Comercial Page)
http://www.cygnus.com/misc/gnu-win32/                (Project Page)
http://www.cygnus.com/ml/gnu-win32                   (Mail Archives)
http://www.itribe.net/virtunix/winhelp-man-pages/    (HTML Man Pages)
http://www.lexa.ru/sos                               (Sergey Okhapkin)
ftp://www.lexa.ru/pub/domestic/sos/                (Sergey's ftp site)
http://www.fu.is.saga-u.ac.jp/~colin/gcc.html        (Colin Peters)
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ (Mumit Khan)
http://gnu-win32.paranoia.ru                   (Chuck Bogorad's ports)
ftp://ftp.deninc.com/pub (Den Internet Services - US mirror and ports)


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
@ 1998-01-15  7:36 Earnie Boyd
  0 siblings, 0 replies; 10+ messages in thread
From: Earnie Boyd @ 1998-01-15  7:36 UTC (permalink / raw)
  To: Ulrich.Lauther; +Cc: gnu-win32

>From: Ulrich Lauther <ulrich.lauther@mchp.siemens.de>
>Subject: Re: mysterious bash problem
>To: earnie_boyd@hotmail.com (Earnie Boyd)
>Date: Thu, 15 Jan 1998 00:38:44 +0100 (MET)
>Reply-To: Ulrich.Lauther@mchp.siemens.de
>
>> It might help to see foo.  UNIX shell scripts must begin with #! 
>only if you want to use a shell different from /bin/sh
>
>> /path/to/shelltoexecute.  If you were on UNIX you would then have to 
set 
>> the executable bit on the file properties/permissions.  The 
cygwin.dll 
>> layer tries to mimick as much of UNIX as it can.  Since the file 
doesn't 
>> begin with #! you will not see the executable bit set on the 
permissions 
>> as that is how it determines if the file is executable.
>> 
>> I have noticed that the gnu-win32 bash will try to execute the script 
>> even without the #! indicator.  This is a bug as bash should error 
>> without this indicator.  For more information see the bash.info file.
>> 
>the point that I do not understand is, that if I carry the script to
>another host (via floppy using cp foo //a) it runs just fine there 
under the
>same gnuwin environment.

Well, first off, it can't be the "same gnuwin environment" because they 
are on different hosts.

What does the mount tables of each host look like?  Do you have Sergey's 
patches installed on each host?  What are the environment variables of 
each host?  Etc...

Now that I've learned a bit of history, thanks to Fergus Henderson, my 
best guess is that the file contains line terminators of \r\n.  One host 
runs the file because it's mounts are text!=binary.  The other doesn't 
because it's mounts are text=binary.

-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------

Check out these great gnu-win32 related sites:
ftp://ftp.cygnus.com/pub/gnu-win32/latest/           (ftp site)
http://www.cygnus.com/pubs/gnupro/                   (Comercial Page)
http://www.cygnus.com/misc/gnu-win32/                (Project Page)
http://www.cygnus.com/ml/gnu-win32                   (Mail Archives)
http://www.itribe.net/virtunix/winhelp-man-pages/    (HTML Man Pages)
http://www.lexa.ru/sos                               (Sergey Okhapkin)
ftp://www.lexa.ru/pub/domestic/sos/                (Sergey's ftp site)
http://www.fu.is.saga-u.ac.jp/~colin/gcc.html        (Colin Peters)
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ (Mumit Khan)
http://gnu-win32.paranoia.ru                   (Chuck Bogorad's ports)
ftp://ftp.deninc.com/pub (Den Internet Services - US mirror and ports)


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
  1998-01-13 10:10 Earnie Boyd
@ 1998-01-15  7:26 ` Fergus Henderson
  1998-01-16  2:56 ` Guy Gascoigne - Piggford
  1 sibling, 0 replies; 10+ messages in thread
From: Fergus Henderson @ 1998-01-15  7:26 UTC (permalink / raw)
  To: Earnie Boyd; +Cc: Ulrich.Lauther, gnu-win32

On 13-Jan-1998, Earnie Boyd <earnie_boyd@hotmail.com> wrote:
> 
> Ulrich Lauther <ulrich.lauther@mchp.siemens.de> writes:
> >
> >Let foo be a valid shell script (starting with a ":" in the first line,
> >BTW):
> 
> To execute a script the first non-blank line must begin with
> 
> #! /bin/sh
> 
> where /bin/sh is the path and shell you want to execute.

I think you're missing some history.  Using `:' in the first line to
identify a Bourne shell script (as opposed to `#', for a C-shell script)
actually predates the `#!' convention.

If gnu-win32 doesn't support execution of shell scripts starting with
`:', then this is a bug in gnu-win32.  It works fine with other Unix
systems, including Linux.

In any case, the form of the error message

> >bash.exe: ./foo: (null)

is clearly a bug.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: < http://www.cs.mu.oz.au/~fjh >   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
  1998-01-13  0:48 Ulrich Lauther
@ 1998-01-14 13:18 ` Guy Gascoigne - Piggford
  0 siblings, 0 replies; 10+ messages in thread
From: Guy Gascoigne - Piggford @ 1998-01-14 13:18 UTC (permalink / raw)
  To: Ulrich.Lauther, gnu-win32

You need to save your shell script as a UNIX file and not as a DOS one.

Guy

At 09:31 AM 1/13/98 +0100, Ulrich Lauther wrote:
>Let foo be a valid shell script (starting with a ":" in the first line, BTW):
>
>bash$ foo
>
>gives:
>
>bash.exe: ./foo: (null)
>
>however,
>
>bash$ bash foo
>
>results in normal execution of the script

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: mysterious bash problem
@ 1998-01-13 10:10 Earnie Boyd
  1998-01-15  7:26 ` Fergus Henderson
  1998-01-16  2:56 ` Guy Gascoigne - Piggford
  0 siblings, 2 replies; 10+ messages in thread
From: Earnie Boyd @ 1998-01-13 10:10 UTC (permalink / raw)
  To: Ulrich.Lauther; +Cc: gnu-win32

>From: Ulrich Lauther <ulrich.lauther@mchp.siemens.de>
>Subject: mysterious bash problem
>To: gnu-win32@cygnus.com
>Date: Mon, 12 Jan 1998 13:08:27 +0100 (MET)
>Reply-To: Ulrich.Lauther@mchp.siemens.de
>
>On one NT host where I don't know who fiddled with what happens
>the following:
>
>Let foo be a valid shell script (starting with a ":" in the first line, 
BTW):

To execute a script the first non-blank line must begin with

#! /bin/sh

where /bin/sh is the path and shell you want to execute.

>
>bash$ foo
>
>gives:
>
>bash.exe: ./foo: (null)
>
>however,
>
>bash$ bash foo

This would be as expected since the shell execution wasn't set properly.

>
>results in normal execution of the script
>
>this doesn't happen with all scripts, just some.
>
>ls -l gives -rw-r--r-- in all cases
>
>What the hell is going on here?
>-- 
>	-ulrich
>
>----------------------------------------------------------------------------
>Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
>Siemens ZT SE 4         Internet: Ulrich.Lauther@mchp.siemens.de
>-
>For help on using this list (especially unsubscribing), send a message 
to
>"gnu-win32-request@cygnus.com" with one line of text: "help".
>


-        \\||//
---o0O0--Earnie--0O0o----
-earnie_boyd@hotmail.com-
------ooo0O--O0ooo-------

Check out these great gnu-win32 related sites:
ftp://ftp.cygnus.com/pub/gnu-win32/latest/           (ftp site)
http://www.cygnus.com/pubs/gnupro/                   (Comercial Page)
http://www.cygnus.com/misc/gnu-win32/                (Project Page)
http://www.cygnus.com/ml/gnu-win32                   (Mail Archives)
http://www.itribe.net/virtunix/winhelp-man-pages/    (HTML Man Pages)
http://www.lexa.ru/sos                               (Sergey Okhapkin)
ftp://www.lexa.ru/pub/domestic/sos/                (Sergey's ftp site)
http://www.fu.is.saga-u.ac.jp/~colin/gcc.html        (Colin Peters)
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/ (Mumit Khan)
http://gnu-win32.paranoia.ru                         (Chuck Bogorad)
ftp://ftp.deninc.com/pub                       (Den Internet Services)


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* mysterious bash problem
@ 1998-01-13  0:48 Ulrich Lauther
  1998-01-14 13:18 ` Guy Gascoigne - Piggford
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Lauther @ 1998-01-13  0:48 UTC (permalink / raw)
  To: gnu-win32

On one NT host where I don't know who fiddled with what happens
the following:

Let foo be a valid shell script (starting with a ":" in the first line, BTW):

bash$ foo

gives:

bash.exe: ./foo: (null)

however,

bash$ bash foo

results in normal execution of the script

this doesn't happen with all scripts, just some.

ls -l gives -rw-r--r-- in all cases

What the hell is going on here?
-- 
	-ulrich

----------------------------------------------------------------------------
Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
Siemens ZT SE 4         Internet: Ulrich.Lauther@mchp.siemens.de
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

* mysterious bash problem
@ 1998-01-12  4:45 Ulrich Lauther
  0 siblings, 0 replies; 10+ messages in thread
From: Ulrich Lauther @ 1998-01-12  4:45 UTC (permalink / raw)
  To: gnu-win32

On one NT host where I don't know who fiddled with what happens
the following:

Let foo be a valid shell script (starting with a ":" in the first line, BTW):

bash$ foo

gives:

bash.exe: ./foo: (null)

however,

bash$ bash foo

results in normal execution of the script

this doesn't happen with all scripts, just some.

ls -l gives -rw-r--r-- in all cases

What the hell is going on here?
-- 
	-ulrich

----------------------------------------------------------------------------
Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
Siemens ZT SE 4         Internet: Ulrich.Lauther@mchp.siemens.de
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1998-01-17 22:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-16  2:56 mysterious bash problem Earnie Boyd
1998-01-17 22:49 ` $Bill Luebkert
  -- strict thread matches above, loose matches on Subject: below --
1998-01-16  2:56 Earnie Boyd
1998-01-15  7:36 Earnie Boyd
1998-01-13 10:10 Earnie Boyd
1998-01-15  7:26 ` Fergus Henderson
1998-01-16  2:56 ` Guy Gascoigne - Piggford
1998-01-13  0:48 Ulrich Lauther
1998-01-14 13:18 ` Guy Gascoigne - Piggford
1998-01-12  4:45 Ulrich Lauther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).