linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: binfmt_script and ^M
  2001-02-27 13:42 binfmt_script and ^M Heusden, Folkert van
@ 2001-02-27 13:38 ` Ivo Timmermans
  2001-02-27 19:20   ` Jamie Lokier
  2001-02-27 21:35   ` Rogier Wolff
  2001-02-27 14:01 ` Bruce Harada
  1 sibling, 2 replies; 8+ messages in thread
From: Ivo Timmermans @ 2001-02-27 13:38 UTC (permalink / raw)
  To: Heusden, Folkert van; +Cc: linux-kernel

Heusden, Folkert van wrote:
> > When running a script (perl in this case) that has DOS-style newlines
> > (\r\n), Linux 2.4.2 can't find an interpreter because it doesn't
> > recognize the \r.  The following patch should fix this (untested).
> 
> _should_ it work with the \r in it?

IMHO, yes.  This set of files were created on Windows, then zipped and
uploaded to a Linux server, unpacked.  This does not change the \r.

> There might be a problem with your patch: at the '*)': if the '\n' is the
> first character on the line, the cp-1 (which should be *(cp-1) I think)

You're right there.

> would point before the buffer which can be un-allocated memory.

No, the first two characters are always `#!'.

> +	if (cp - 1 == '\r')				<------- *)


-- 
Ivo Timmermans

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

* RE: binfmt_script and ^M
@ 2001-02-27 13:42 Heusden, Folkert van
  2001-02-27 13:38 ` Ivo Timmermans
  2001-02-27 14:01 ` Bruce Harada
  0 siblings, 2 replies; 8+ messages in thread
From: Heusden, Folkert van @ 2001-02-27 13:42 UTC (permalink / raw)
  To: Ivo Timmermans, linux-kernel

> When running a script (perl in this case) that has DOS-style newlines
> (\r\n), Linux 2.4.2 can't find an interpreter because it doesn't
> recognize the \r.  The following patch should fix this (untested).

_should_ it work with the \r in it?

There might be a problem with your patch: at the '*)': if the '\n' is the
first character on the line, the cp-1 (which should be *(cp-1) I think)
would point before the buffer which can be un-allocated memory.



--- binfmt_script.c~	Mon Feb 26 17:42:09 2001
+++ binfmt_script.c	Tue Feb 27 13:39:47 2001
@@ -36,6 +36,8 @@
 	bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
 	if ((cp = strchr(bprm->buf, '\n')) == NULL)
 		cp = bprm->buf+BINPRM_BUF_SIZE-1;
+	if (cp - 1 == '\r')				<------- *)
+	  cp--;
 	*cp = '\0';
 	while (cp > bprm->buf) {
 		cp--;


Greetings,
Folkert van Heusden
[ www.vanheusden.com ]

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

* Re: binfmt_script and ^M
  2001-02-27 13:42 binfmt_script and ^M Heusden, Folkert van
  2001-02-27 13:38 ` Ivo Timmermans
@ 2001-02-27 14:01 ` Bruce Harada
  1 sibling, 0 replies; 8+ messages in thread
From: Bruce Harada @ 2001-02-27 14:01 UTC (permalink / raw)
  To: Ivo Timmermans; +Cc: linux-kernel

On Tue, 27 Feb 2001 14:38:23 +0100
Ivo Timmermans <irt@cistron.nl> wrote:
> Heusden, Folkert van wrote:
> > > When running a script (perl in this case) that has DOS-style
> newlines
> > > (\r\n), Linux 2.4.2 can't find an interpreter because it doesn't
> > > recognize the \r.  The following patch should fix this (untested).
> > 
> > _should_ it work with the \r in it?
> 
> IMHO, yes.  This set of files were created on Windows, then zipped and
> uploaded to a Linux server, unpacked.  This does not change the \r.

Unzipping the files with the "-ll" option should fix that. There's no
particular reason why the kernel should handle CR+LF; LF has been the
end-of-line character for UN*X systems since Adam was a cowboy.
Changing it now would only lead to a situation where some things would
work with CR+LF and others wouldn't. Let's keep it simple...

--
Bruce Harada
bruce@ask.ne.jp


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

* Re: binfmt_script and ^M
  2001-02-27 13:38 ` Ivo Timmermans
@ 2001-02-27 19:20   ` Jamie Lokier
  2001-02-27 19:59     ` Don Dugger
  2001-02-27 21:35   ` Rogier Wolff
  1 sibling, 1 reply; 8+ messages in thread
From: Jamie Lokier @ 2001-02-27 19:20 UTC (permalink / raw)
  To: Ivo Timmermans; +Cc: Heusden, Folkert van, linux-kernel

Ivo Timmermans wrote:
> > _should_ it work with the \r in it?
> 
> IMHO, yes.  This set of files were created on Windows, then zipped and
> uploaded to a Linux server, unpacked.  This does not change the \r.

Use `fromdos' to convert the files.  Or this little Perl gem, which
takes a list of files or standard input as argument:

#!/usr/bin/perl -pi
s/\r\n$/\n/

-- Jamie

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

* Re: binfmt_script and ^M
  2001-02-27 19:20   ` Jamie Lokier
@ 2001-02-27 19:59     ` Don Dugger
  2001-02-27 21:36       ` [OT] " Tim Waugh
  0 siblings, 1 reply; 8+ messages in thread
From: Don Dugger @ 2001-02-27 19:59 UTC (permalink / raw)
  To: Jamie Lokier; +Cc: linux-kernel

Isn't `perl' overkill?  Why not just:

	tr -d '\r'

On Tue, Feb 27, 2001 at 08:20:59PM +0100, Jamie Lokier wrote:
> Ivo Timmermans wrote:
> > > _should_ it work with the \r in it?
> > 
> > IMHO, yes.  This set of files were created on Windows, then zipped and
> > uploaded to a Linux server, unpacked.  This does not change the \r.
> 
> Use `fromdos' to convert the files.  Or this little Perl gem, which
> takes a list of files or standard input as argument:
> 
> #!/usr/bin/perl -pi
> s/\r\n$/\n/
> 
> -- Jamie
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano@valinux.com
Ph: 303/938-9838

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

* Re: binfmt_script and ^M
  2001-02-27 13:38 ` Ivo Timmermans
  2001-02-27 19:20   ` Jamie Lokier
@ 2001-02-27 21:35   ` Rogier Wolff
  1 sibling, 0 replies; 8+ messages in thread
From: Rogier Wolff @ 2001-02-27 21:35 UTC (permalink / raw)
  To: Ivo Timmermans; +Cc: Heusden, Folkert van, linux-kernel

Ivo Timmermans wrote:
> Heusden, Folkert van wrote:
> > > When running a script (perl in this case) that has DOS-style newlines
> > > (\r\n), Linux 2.4.2 can't find an interpreter because it doesn't
> > > recognize the \r.  The following patch should fix this (untested).
> > 
> > _should_ it work with the \r in it?
> 
> IMHO, yes.  This set of files were created on Windows, then zipped and
> uploaded to a Linux server, unpacked.  This does not change the \r.

Use the right option on "unzip" to unpack with cr/lf conversion.

Otherwise, use a script that does it afterwards. 

			Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
* There are old pilots, and there are bold pilots. 
* There are also old, bald pilots. 

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

* [OT] Re: binfmt_script and ^M
  2001-02-27 19:59     ` Don Dugger
@ 2001-02-27 21:36       ` Tim Waugh
  2001-02-27 23:16         ` Jamie Lokier
  0 siblings, 1 reply; 8+ messages in thread
From: Tim Waugh @ 2001-02-27 21:36 UTC (permalink / raw)
  To: Don Dugger; +Cc: Jamie Lokier, linux-kernel

On Tue, Feb 27, 2001 at 12:59:48PM -0700, Don Dugger wrote:

> Isn't `perl' overkill?  Why not just:
> 
> 	tr -d '\r'

while read line; do echo ${line%?}; done

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

* Re: [OT] Re: binfmt_script and ^M
  2001-02-27 21:36       ` [OT] " Tim Waugh
@ 2001-02-27 23:16         ` Jamie Lokier
  0 siblings, 0 replies; 8+ messages in thread
From: Jamie Lokier @ 2001-02-27 23:16 UTC (permalink / raw)
  To: Tim Waugh; +Cc: Don Dugger, linux-kernel

Tim Waugh wrote:
> > Isn't `perl' overkill?  Why not just:
> > 
> > 	tr -d '\r'
> 
> while read line; do echo ${line%?}; done

And those can be convert a set of files as "fromdos *.c" can they?

:-)
-- Jamie

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

end of thread, other threads:[~2001-02-27 23:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-27 13:42 binfmt_script and ^M Heusden, Folkert van
2001-02-27 13:38 ` Ivo Timmermans
2001-02-27 19:20   ` Jamie Lokier
2001-02-27 19:59     ` Don Dugger
2001-02-27 21:36       ` [OT] " Tim Waugh
2001-02-27 23:16         ` Jamie Lokier
2001-02-27 21:35   ` Rogier Wolff
2001-02-27 14:01 ` Bruce Harada

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 NNTP newsgroup(s).