This is the mail archive of the cygwin-apps mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ITP dos2unix 5.2.1-1

Moved to main cygwin list for more feedback.

Background: currently the following utilities
are all provided by the cygutils package. They are, in fact, all
hardlinks/copies of the same 'conv.exe' program, developed specifically
for cygwin.

We have a proposal to provide the "dos2unix" package instead, and
removing these utilities from cygutils.  For more info, see:
and following.

On 3/16/2011 4:18 PM, Christopher Faylor wrote:
> Ah, right.
> I didn't get that Eric was referring to this scenario but, regardless,
> I should have remembered that alternatives means using symlinks.  Given
> the use that d2u is put, I don't think we want to make it a symlink.
> So, I guess that means that we poll the community if we want to go ahead
> with this.  Either that or the binaries in the new package are given a
> different name to avoid conflicts.

Given that the unix2dos package supports pipe operation, the only real
difference is the command line options (and following symlinks on
converted files).

So, compare:

unix2dos 5.1.1 (2010-08-18)
Usage: unix2dos [-fhkLlqV] [-c convmode] [-o file ...] [-n infile
outfile ...]
 -c --convmode    conversion mode
   convmode       ascii, 7bit, iso, mac, default to ascii
 -f --force       force conversion of all files
 -h --help        give this help
 -k --keepdate    keep output file date
 -L --license     display software license
 -l --newline     add additional newline
 -n --newfile     write to new file
   infile         original file in new file mode
   outfile        output file in new file mode
 -o --oldfile     write to old file
   file ...       files to convert in old file mode
 -q --quiet       quiet mode, suppress all warnings
                  always on in stdio mode
 -V --version     display version number


unix2dos is part of cygutils version 1.4.4
  converts the line endings of text files from
  UNIX style (0x0a) to DOS style (0x0d 0x0a)

Usage: unix2dos [OPTION...] [input file list...]

Main options (not all may apply)
  -A, --auto     Output format will be the opposite of the autodetected
  -D, --u2d      Output will be in DOS format
  --unix2dos     Output will be in DOS format
  -U, --d2u      Output will be in UNIX format
  --dos2unix     Output will be in UNIX format
  --force        Ignore binary file detection
  --safe         Do not modify binary files

Help options
  -?, --help     Show this help message
  --usage        Display brief usage message
  --version      Display version information
  --license      Display licensing information

Other arguments
  [input file list...]       for each file listed, convert in place.
                             If none specified, then use stdin/stdout

Now, of the cygutils options, we don't need
  -D, --u2d, --unix2dos
  -U, --d2u, --dos2unix
because...those really only apply to the generic 'conv.exe' application.
cygutils' unix2dos app is really only supposed to be used in, well,
unix2dos mode!  So, unix2dos explicitly disallows the use of the
"opposite" options (--dos2unix etc) and --auto; similarly dos2unix:

  if (progtype == CT_UNIX2DOS) {
    if (opts.ConvType != CT_UNIX2DOS) {
              "%s: cannot accept any conversion type argument other\n" \

Similarly, we don't need
  -A, --auto
because, again, it really only makes sense for the generic conv.exe app
(and u2d/d2u/etc explicitly disallow its use).

All that leaves are the informational options (--help, -?, --usage,
--version, --license) which, if they go missing or renamed, I doubt that
will break any scripts.

Finally, we have
  --force        Ignore binary file detection
  --safe         Do not modify binary files
All of cygutils' conversion progs operate in safe mode by default, so
the --safe option is a bit redundant (it was added so that if somebody
aliased unix2dos as 'unix2dos --force', they could override on the cmd
line using --safe if necessary).

The proposed package provides a similar --force option, but no --safe.

So, the only real issues are

	1) somebody is (redundantly) specifying --safe
	2) how does the unix2dos "binary detection algorithm" differ
	   from cygutils'?
	3) Does the unix2dos package handle setmode() on stdio properly?
	4) Ditto for O_BINARY on physical files?
	5) cygutils always follows symlinks. This new package does not,
	   unless --force, according to the man page (which is
	   unfortunate: the same option means "follow symlinks" AND
	   "convert everything even if you think it is binary"
	6) dos2unix foo.h foo.c (cygutils), but according to the manpage
	     dos2unix -o foo.h foo.c (new package)
	   However, experimentation shows the man page is wrong.
	     dos2unix foo.h foo.c (new package)
	   works fine.
	7) Output messages:
	   cygutils: $ dos2unix bob.c bob.h
		       bob.c: done.
		       bob.h: done.
		on stderr

	   newpkg:   $ dos2unix bob.c bob.h
		     dos2unix: converting file bob.c to UNIX format ...
		     dos2unix: converting file bob.h to UNIX format ...
		on stderr
	8) output status -- both packages report '0' on success, where
	   success means "nothing went wrong".  That is, if you convert
	   a file with unix LE using dos2unix, no changes are made to
	   the file AND 0 status is returned.  Again, this behavior is
	   the same on both pkgs, I just thought it was interesting.

I think 2-4 are manageable (but need investigation), and *I* am willing
to break users who are relying on --safe.  Or cygwin's version of the
new package could be patched to add a --safe option.

5: if the new package is used, I think we should patch it to always
follow symlinks (or add a new option, and make it default to follow).

7: This might cause a problem if some script is relying on the output
messages of the utility.  I think this is bad practice, and am willing
to break people that are doing this.

So: I don't see any insurmountable problems with entirely replacing
cygutils' unix2dos/dos2unix/u2d/d2u programs with these other versions.
 (I would hope that cygwin's package would provide a u2d.exe hardlinked
to unix2dos.exe, etc)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]