mksh 49-1 no longer handles Windows line endings

Ryan Dortmans ryandort.cygwin@gmail.com
Thu Dec 11 01:20:00 GMT 2014


Hi,

The latest version of mksh no longer handles Windows line endings in
ksh scripts when in a text-mode file system.

To reproduce:

$ mount -o text c:/textmode /textmode
(or use an existing text-mode mount)

$ echo -e "\necho \"test\"\n" > /textmode/test.ksh
$ ksh /textmode/test.ksh
: not foundsh[1]:
test
: not foundsh[3]:

$ d2u /textmode/test.ksh
dos2unix: converting file /textmode/test.ksh to Unix format...

$ ksh /textmode/test.ksh
test

Reverting to 48b-1 and retesting gives the correct behaviour
regardless of whether it has dos or unix line endings.


I have investigated the differences in the source code of the two
versions and found that 49-1 added O_BINARY flag to all of the open
calls. I took these flags out and was able to confirm that it fixes
the issue. I have attached two patches that do the same thing. One
removes the flag, the other commented out the #ifdef O_BINARY line in
the header so that #define O_BINARY 0 is always defined. These aren't
intended as actual patches to mksh, merely examples of how to fix the
issue.

The mksh changelog (https://www.mirbsd.org/mksh.htm#clog), indicates
why this change was made:
[tg] Add O_BINARY to all open(2) calls for OS/2 kLIBC support

The website also indicates that "No workarounds for .exe suffixes or
other platform-specific quirks have been or will be added." So I doubt
I could get this fixed upstream. Could the maintainer please take a
look at this?

Cheers,

Ryan Dortmans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mksh491_fix1.patch
Type: application/octet-stream
Size: 4118 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141211/1ede6458/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mksh491_fix2.patch
Type: application/octet-stream
Size: 382 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141211/1ede6458/attachment-0001.obj>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list