Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #173389
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: My bash script is missing something - what? |
| Date | 2016-10-10 16:20 +0200 |
| Message-ID | <sqJAS-2hV-1@gated-at.bofh.it> (permalink) |
| References | <sqIlx-1ni-27@gated-at.bofh.it> <sqIv8-1FC-37@gated-at.bofh.it> <sqIEO-1J7-13@gated-at.bofh.it> <sqIOu-1Mr-7@gated-at.bofh.it> <sqJAS-2hV-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Oct 10, 2016 at 04:10:22PM +0200, Nicolas George wrote:
> Le nonidi 19 vendémiaire, an CCXXV, Greg Wooledge a écrit :
> > > That just fails differently by responding:
> > >
> > > : No such file or directory
> >
> > Carriage return. Did you edit this script with a Microsoft Windows
> > program, perhaps? The shebang line (#!/bin/bash) probably ends with
> > a carriage return + line feed, instead of just a line feed.
>
> I had the same diagnosis. Note that modern shells print a more useful
> diagnosis:
>
> execve("/tmp/foo.sh", ["/tmp/foo.sh"], [/* 45 vars */]) = -1 ENOENT (No such file or directory)
> open("/tmp/foo.sh", O_RDONLY|O_NOCTTY) = 3
> read(3, "#!/bin/sh\r\n", 64) = 11
> close(3) = 0
> ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> write(2, "zsh:1: /tmp/foo.sh: bad interpreter: /bin/sh^M: no such file or directory\n", 74) = 74
> exit_group(127) = ?
Actually, I'm going to change my diagnosis slightly. The shebang is fine,
but the "cat /etc/debian_version" line has a carriage return at the end.
The error message is coming from cat.
If the shebang is wrong, bash (as interactive shell) prints:
bash: ./foo: /bin/bash^M: bad interpreter: No such file or directory
which is very close to your zsh message. But putting the carriage return
on the cat command gives:
wooledg@wooledg:~$ ./foo
: No such file or directory
which is really:
wooledg@wooledg:~$ ./foo 2>&1 | less
cat: /etc/debian_version^M: No such file or directory
How the original poster ended up with a script with an extra carriage
return on just *one* line, rather than every line, is a mystery to me.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
My bash script is missing something - what? Richard Owlett <rowlett@cloud85.net> - 2016-10-10 15:00 +0200
Re: My bash script is missing something - what? Robert Parker <rlp1938@gmail.com> - 2016-10-10 15:10 +0200
Re: My bash script is missing something - what? Richard Owlett <rowlett@cloud85.net> - 2016-10-10 15:20 +0200
Re: My bash script is missing something - what? Robert Parker <rlp1938@gmail.com> - 2016-10-10 15:30 +0200
Re: My bash script is missing something - what? Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-10 15:30 +0200
Re: My bash script is missing something - what? Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-10 16:20 +0200
Re: My bash script is missing something - what? Nicolas George <george@nsup.org> - 2016-10-10 16:20 +0200
PROGRESS - was [Re: My bash script is missing something - what?] Richard Owlett <rowlett@cloud85.net> - 2016-10-10 17:00 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Nicolas George <george@nsup.org> - 2016-10-10 17:10 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Richard Owlett <rowlett@cloud85.net> - 2016-10-10 17:50 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Peter Hillier-Brook <phb@hbsys.plus.com> - 2016-10-10 18:30 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-10 18:40 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-10 17:10 +0200
Re: PROGRESS - was [Re: My bash script is missing something - what?] Richard Owlett <rowlett@cloud85.net> - 2016-10-10 17:50 +0200
Re: My bash script is missing something - what? Lars Noodén <lars.nooden@gmail.com> - 2016-10-10 15:30 +0200
Re: My bash script is missing something - what? "Thomas Schmitt" <scdbackup@gmx.net> - 2016-10-10 15:40 +0200
Re: My bash script is missing something - what? Greg Wooledge <wooledg@eeg.ccf.org> - 2016-10-10 18:00 +0200
Re: My bash script is missing something - what? songbird <songbird@anthive.com> - 2016-10-10 18:00 +0200
csiph-web