27 Oct 17:55
Re: trying to build msys from source
On Saturday 25 October 2008 02:39:06 John Clizbe wrote:
> > need unix2dos in mingw-utils
>
> If you've installed perl, which is probably a safe bet:
I'm no perl expert, and I'm sorry to disappoint, but...
> jpclizbe <at> yogi:~$ cat << EOF > /usr/local/bin/unix2dos
> #!/usr/bin/perl -pi
> s/\n/\r\n/;
> EOF
...this doesn't work; it is broken, for any file which already has
CRLF line endings. Correct behaviour is to insert the missing CR
*only* for those lines which do not already have it in place.
However, ...
> jpclizbe <at> yogi:~$ cat << EOF /usr/local/bin/dos2unix
> #!/usr/bin/perl -pi
> s/\r\n/\n/;
> EOF
...this looks like it should probably be ok. (The `sed -n p'
alternative, which I suggested, is also effective).
The script which I actually use is rather more sophisticated, being a
complete emulation of Cygwin's composite unix2dos/dos2unix tool. It
is attached, but for reference, it does the equivalent of:
<script name=unix2dos>
#!/bin/sh
awk '{sub("\r$",""); printf "%s\r\n", $0}' "$@"
</script>
<script name=dos2unix>
#!/bin/sh
awk '{sub("\r$",""); printf "%s\n", $0}' "$@"
</script>
Note that this pair may also be written as:
<script name=unix2dos>
#!/bin/awk -f
{sub("\r$",""); printf "%s\r\n", $0}
</script>
<script name=dos2unix>
#!/bin/awk -f
{sub("\r$",""); printf "%s\n", $0}
</script>
or, for dos2unix, this also works, (but it's fragile and obscure,
because it relies on a quirk of the current MSYS sed -- it always
converts CRLF to LF on output, regardless of the input format; this
could easily break in a future release):
<script name=dos2unix>
#!/bin/sed -nf
p
</script>
These are more like John's perl variants in coding structure, and may
be slightly more efficient than the shell script variants.
Regards,
Keith.
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Mingw-msys mailing list Mingw-msys@... https://lists.sourceforge.net/lists/listinfo/mingw-msys
RSS Feed