Subject: bug#24055: closed (Re: bug#24055: Bug: #!/usr/bin/env gives poor error message for DOS line-endings)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 22 Jul 2016 22:59:02 +0000

Your bug report

#24055: Bug: #!/usr/bin/env gives poor error message for DOS line-endings

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
24055: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24055
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#24055: Bug: #!/usr/bin/env gives poor error message for DOS line-endings
From: Pádraig Brady <[email-masked]>
To: Simon Richard Clarkstone <[email-masked]>, [email-masked]
Date: Fri, 22 Jul 2016 23:57:58 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On 22/07/16 21:39, Simon Richard Clarkstone wrote:
> I have found a poor error message in env (GNU coreutils) 8.23, on FC22.
> 
> ---
> 
> I created the following executable file, with a DOS line-end:
> 
> #!/usr/bin/env sh
> 
> When run, it displays the following error message on my terminal:
> 
> : No such file or directory
> 
> This error message is cryptic.  However, if you process stderr through 
> `cat -v` to display nonprintable characters, you find the error message 
> has a CR in it:
> 
> /usr/bin/env: sh^M: No such file or directory

That's fixed by the new file name quoting in coreutils 8.25.
The new output is:

/usr/bin/env: ‘sh\r’: No such file or directory

thanks,
Pádraig.

Subject: Bug: #!/usr/bin/env gives poor error message for DOS line-endings
From: Simon Richard Clarkstone <[email-masked]>
To: [email-masked]
Date: Fri, 22 Jul 2016 21:39:58 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

I have found a poor error message in env (GNU coreutils) 8.23, on FC22.

---

I created the following executable file, with a DOS line-end:

#!/usr/bin/env sh

When run, it displays the following error message on my terminal:

: No such file or directory

This error message is cryptic.  However, if you process stderr through 
`cat -v` to display nonprintable characters, you find the error message 
has a CR in it:

/usr/bin/env: sh^M: No such file or directory

and the CR caused the second half of the error message to over-write the 
first half when displayed on-screen.

---

To diagnose the problem I had to use strace, so IMO this error message 
could be improved by expanding out control characters.  For example see 
how bash handles an analogous situation, with the script:

#!/usr/bin/sh

Which displays:

bash: ./tmp.sh: /usr/bin/sh^M: bad interpreter: No such file or directory

Here, bash has expanded out the ^M before displaying it, showing that 
something is stuck on the end of the #! line.

-- 
Simon Richard Clarkstone, CoreFiling Limited
Software Engineer, Data Modelling
http://www.corefiling.com/
Phone: +44-1865-203192