ls should colorize .cgm and .emf files as image files

2009-10-01 Thread James R. Van Zandt

I suggest that ls should colorize .cgm and .emf files as image
files, e.g. using the following patch.

FWIW, file currently recognizes .emf files but not .cgm files:
  $ file *emf
  ellipse-illustrator.emf: Windows Enhanced Metafile (EMF) image data
  version 0x1
  $ file damped.cgm
  damped.cgm: data

.cgm files are Computer Graphcs Metafiles, defined by IISO/IEC 8632.
  
I hereby assign the copyright for this patch to the Free Software
Foundation.

 - Jim Van Zandt


--- src/dircolors.hin-orig  2009-09-24 18:46:38.0 -0400
+++ src/dircolors.hin   2009-09-24 18:48:01.0 -0400
@@ -132,6 +132,8 @@
 .jpeg 01;35
 .gif 01;35
 .bmp 01;35
+.cgm 01;35
+.emf 01;35
 .pbm 01;35
 .pgm 01;35
 .ppm 01;35




-T option help text

2009-09-03 Thread James R. Van Zandt

Philip Rowlands wrote:
 On Sun, 30 Aug 2009, James R. Van Zandt wrote:
 
 
   For the help text, here are some alternatives:
 
 
   if DEST is a directory, then delete it first 
 
 
 This isn't what -T does. If DEST is an empty directory then it's
 overwritten with the rename(2) system call. Otherwise mv will fail
 e.g. if SOURCE isn't a directory or DEST is non-empty.

Let's see...

  vanzandt:/tmp$ date source
  vanzandt:/tmp$ mkdir dest
  vanzandt:/tmp$ mv -T source dest
  mv: cannot overwrite directory `dest' with non-directory
  vanzandt:/tmp$ rm -rf dest
  vanzandt:/tmp$ touch test
  vanzandt:/tmp$ mv -T source dest
  vanzandt:/tmp$ 
  
I agree my proposed help text is wrong.  However, I think the current
description in the info file is wrong too.  It says Do not treat the
last operand specially when it is a directory or a symbolic link to a
directory.  Yet, this is an example where mv fails when DEST is a
directory, and succeeds when it is a normal file.  So a directory *is*
treated differently.

The extended discussion on the Target directory page says:

 For example, when the command `mv /tmp/source /tmp/dest'
 succeeds, there is no guarantee that `/tmp/source' was renamed to
 `/tmp/dest': it could have been renamed to `/tmp/dest/source'
 instead, if some other process created `/tmp/dest' as a
 directory.  However, if `mv -T /tmp/source /tmp/dest' succeeds,
 there is no question that `/tmp/source' was renamed to
 `/tmp/dest'.

I read the last sentence as saying /tmp/source would get renamed as
/tmp/dest whether or not some other process had previously created
/tmp/dest as a directory.  The fact that it fails instead certainly
should be stated.  (To me it seems a much less useful behavior.)

- Jim Van Zandt








-T option help text

2009-08-30 Thread James R. Van Zandt

Kamil Dudka wrote:
On Sunday 30 of August 2009 03:11:34 James R. Van Zandt wrote:
 ...(I'd first have to check the help printout to
 see that it's not -T I wanted after all.  Then check the info page,
 because the -T description is so unhelpful.  But that's a separate
 issue.)

 What exactly is unhelpful on the -T description? We'll be happy to
 improve the description if you come with something better.

The current help entry is:

  -T, --no-target-directorytreat DEST as a normal file

A long option is supposed to be more or less self documenting, but
this long option doesn't tell me anything.  I find myself asking No
target directory?  But there's *always* a target directory!

I find the help text pretty obscure too.  Of the various things DEST
could be besides a regular file (symbolic link, device, pipe...) what
would it mean to treat it as a regular file?  After reading the info
page, I have to admit that the help text is technically correct.
However, if it can't be understood without reading the info page, then
it is not doing its job.

For the help text, here are some alternatives:

if DEST is a directory, then delete it first

This is short, but doesn't handle the case of DEST being a
symbolic link

if DEST is a directory, or a symbolic link to a directory, then delete it 
first

correct but wordy

if DEST exists, then delete it first (even if it's a directory)

I prefer this.


I'd really like to change the long option too.  It should not be
saying there is no target directory but rather that the second
operand is not naming a target directory.  A couple possibilities:

  --rm-target-first
  --rm-dest-first

However, I am not really happy with either one.

   - Jim Van Zandt






--to option for mv and friends

2009-08-30 Thread James R. Van Zandt

Jim Meyering wrote:
 Considering all the talk of DEST and destination, I can see how
 the use of target in that option name can make it harder to remember.
 A new option might be worthwhile after all.

Thanks.

 However, --to=... might make someone think that the
 argument could be a non-directory.

Well, the help entry

   ... --to=DIRECTORY ...

makes it pretty clear.  Also, the first time he tried it with a
non-directory argument, it would fail with an explanation.

 So how about --to-dir=..., which could still be abbreviated to --to.

I'd accept that reluctantly - provided the info page includes an
example using the abbreviation.  (As an aside, the info page says
Most programs that accept long options recognize unambiguous
abbreviations of those options, but I couldn't find any statement
that mv does.)  

I'm attaching a revised patch along those lines.  (I put the example
on each program's info page, rather than on the separate target
directory page, because I suspect each additional link loses at least
half the users.)

I hereby assign the copyright for this patch to the Free Software
Foundation.

- Jim Van Zandt

--- ../coreutils-7.4.orig/src/cp.c  2009-04-24 08:50:28.0 -0400
+++ src/cp.c2009-08-30 15:05:21.0 -0400
@@ -125,6 +125,7 @@
   {suffix, required_argument, NULL, 'S'},
   {symbolic-link, no_argument, NULL, 's'},
   {target-directory, required_argument, NULL, 't'},
+  {to-dir, required_argument, NULL, 't'},
   {update, no_argument, NULL, 'u'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -201,7 +202,8 @@
   fputs (_(\
   -s, --symbolic-link  make symbolic links instead of copying\n\
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -t, --to-dir=DIRECTORY, --target-directory=DIRECTORY  copy all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directorytreat DEST as a normal file\n\
 ), stdout);
   fputs (_(\
--- ../coreutils-7.4.orig/src/install.c 2009-04-24 08:59:06.0 -0400
+++ src/install.c   2009-08-30 15:05:21.0 -0400
@@ -157,6 +157,7 @@
   {strip-program, required_argument, NULL, STRIP_PROGRAM_OPTION},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to-dir, required_argument, NULL, 't'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -980,7 +981,8 @@
   -s, --strip strip symbol tables\n\
   --strip-program=PROGRAM  program used to strip binaries\n\
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -t, --to-dir=DIRECTORY, --target-directory=DIRECTORY  copy all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directory  treat DEST as a normal file\n\
   -v, --verbose   print the name of each directory as it is created\n\
 ), stdout);
--- ../coreutils-7.4.orig/src/ln.c  2009-04-24 08:41:19.0 -0400
+++ src/ln.c2009-08-30 15:05:21.0 -0400
@@ -103,6 +103,7 @@
   {interactive, no_argument, NULL, 'i'},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to-dir, required_argument, NULL, 't'},
   {symbolic, no_argument, NULL, 's'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -383,8 +384,8 @@
 ), stdout);
   fputs (_(\
   -S, --suffix=SUFFIX override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create\n\
-the links\n\
+  -t, --to-dir=DIRECTORY, --target-directory=DIRECTORY  specify the 
DIRECTORY\n\
+in which to create the links\n\
   -T, --no-target-directory   treat LINK_NAME as a normal file\n\
   -v, --verbose   print name of each linked file\n\
 ), stdout);
--- ../coreutils-7.4.orig/src/mv.c  2009-05-03 16:05:34.0 -0400
+++ src/mv.c2009-08-30 15:05:21.0 -0400
@@ -62,6 +62,7 @@
   {strip-trailing-slashes, no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to-dir, required_argument, NULL, 't'},
   {update, no_argument, NULL, 'u'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -304,7 +305,8 @@
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
 ), stdout);
   fputs (_(\
-  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY\n\
+  -t, --to-dir=DIRECTORY, --target-directory=DIRECTORY  move all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directorytreat DEST as a normal file\n\
   -u, --update move only when 

--to option for mv and friends

2009-08-29 Thread James R. Van Zandt

 I propose the patch below, which adds the --to option as a synonym for
 --destination-directory, to the programs cp, ln, install, and mv.  

Pardon me - I should have written --target-directory.  But that is
actually my point - I find the current long option hard to remember.

(No, I didn't mis-type it on purpose.)

Kamil Dudka wrote:
 If you think the option --target-directory is too long, you can use
 --ta instead

I'm not trying to reduce typing.  If I just wanted to minimize typing,
I'd use -t.  (However, I'd first have to check the help printout to
see that it's not -T I wanted after all.  Then check the info page,
because the -T description is so unhelpful.  But that's a separate
issue.)  No, -t and certainly the abbreviation --ta would likely
be used only by someone thoroughly familiar with the option set, who
no longer has to refer to the documentation.

My proposal is aimed at someone less familiar with the option set, to
help him use that particular option the second time without having to
refer to the documentation again.

After all, --to makes the command read almost like an English sentence.

 - Jim Van Zandt




--to option for mv and friends

2009-08-28 Thread James R. Van Zandt

I propose the patch below, which adds the --to option as a synonym for
--destination-directory, to the programs cp, ln, install, and mv.  

I think it's easier to remember (and say) something like

 mv  --to MYDIR  myfile  hisfile  theirfile

than with the current long option.

I hereby assign the copyright for this patch to the Free Software
Foundation.

 - Jim Van Zandt


--- ../coreutils-7.4.orig/src/cp.c  2009-04-24 08:50:28.0 -0400
+++ src/cp.c2009-08-28 21:12:00.0 -0400
@@ -125,6 +125,7 @@
   {suffix, required_argument, NULL, 'S'},
   {symbolic-link, no_argument, NULL, 's'},
   {target-directory, required_argument, NULL, 't'},
+  {to, required_argument, NULL, 't'},
   {update, no_argument, NULL, 'u'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -201,7 +202,8 @@
   fputs (_(\
   -s, --symbolic-link  make symbolic links instead of copying\n\
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -t, --to=DIRECTORY, --target-directory=DIRECTORY  copy all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directorytreat DEST as a normal file\n\
 ), stdout);
   fputs (_(\
--- ../coreutils-7.4.orig/src/install.c 2009-04-24 08:59:06.0 -0400
+++ src/install.c   2009-08-28 21:12:53.0 -0400
@@ -157,6 +157,7 @@
   {strip-program, required_argument, NULL, STRIP_PROGRAM_OPTION},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to, required_argument, NULL, 't'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -980,7 +981,8 @@
   -s, --strip strip symbol tables\n\
   --strip-program=PROGRAM  program used to strip binaries\n\
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY\n\
+  -t, --to=DIRECTORY, --target-directory=DIRECTORY  copy all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directory  treat DEST as a normal file\n\
   -v, --verbose   print the name of each directory as it is created\n\
 ), stdout);
--- ../coreutils-7.4.orig/src/ln.c  2009-04-24 08:41:19.0 -0400
+++ src/ln.c2009-08-28 21:13:53.0 -0400
@@ -103,6 +103,7 @@
   {interactive, no_argument, NULL, 'i'},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to, required_argument, NULL, 't'},
   {symbolic, no_argument, NULL, 's'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -383,8 +384,8 @@
 ), stdout);
   fputs (_(\
   -S, --suffix=SUFFIX override the usual backup suffix\n\
-  -t, --target-directory=DIRECTORY  specify the DIRECTORY in which to create\n\
-the links\n\
+  -t, --to=DIRECTORY, --target-directory=DIRECTORY  specify the DIRECTORY\n\
+in which to create the links\n\
   -T, --no-target-directory   treat LINK_NAME as a normal file\n\
   -v, --verbose   print name of each linked file\n\
 ), stdout);
--- ../coreutils-7.4.orig/src/mv.c  2009-05-03 16:05:34.0 -0400
+++ src/mv.c2009-08-28 20:55:47.0 -0400
@@ -62,6 +62,7 @@
   {strip-trailing-slashes, no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
   {suffix, required_argument, NULL, 'S'},
   {target-directory, required_argument, NULL, 't'},
+  {to, required_argument, NULL, 't'},
   {update, no_argument, NULL, 'u'},
   {verbose, no_argument, NULL, 'v'},
   {GETOPT_HELP_OPTION_DECL},
@@ -304,7 +305,8 @@
   -S, --suffix=SUFFIX  override the usual backup suffix\n\
 ), stdout);
   fputs (_(\
-  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY\n\
+  -t, --to=DIRECTORY, --target-directory=DIRECTORY  move all SOURCE 
arguments\n\
+ into DIRECTORY\n\
   -T, --no-target-directorytreat DEST as a normal file\n\
   -u, --update move only when the SOURCE file is newer\n\
  than the destination file or when the\n\
--- ../coreutils-7.4.orig/doc/coreutils.texi2009-05-05 17:24:31.0 
-0400
+++ doc/coreutils.texi  2009-08-28 21:22:37.0 -0400
@@ -552,8 +552,10 @@
 @macro optTargetDirectory
 @item -t @var{directory}
 @itemx @w...@kbd{--target-directory}=@var{directory}}
+...@itemx @w...@kbd{--to}=@var{directory}}
 @opindex -t
 @opindex --target-directory
+...@opindex --to
 @cindex target directory
 @cindex destination directory
 Specify the destination @var{directory}.
@@ -1195,11 +1197,13 @@
 
 In the opposite situation, where you want the last operand to be
 treated as a directory and want a diagnostic otherwise, you can use
-the @option{--target-directory}