]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
don't compute isdir() of -- or an option string
authorJim Meyering <jim@meyering.net>
Sun, 17 Oct 1999 07:39:20 +0000 (07:39 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 17 Oct 1999 07:39:20 +0000 (07:39 +0000)
src/mv.c

index 291b531f0a82602c1104089b1d765ac84d1e341c..41d3a9250664a61ac5bad4ba21227dbfc37f6e25 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
@@ -438,10 +438,14 @@ main (int argc, char **argv)
   file = argv + optind;
 
   target_directory_specified = (target_directory != NULL);
-  if (!target_directory)
-    target_directory = file[n_files - 1];
+  if (target_directory == NULL)
+    {
+      /* Be careful below.  When n_files is 0, this value will be
+        argv[0], `--', or an option string.  */
+      target_directory = file[n_files - 1];
+    }
 
-  dest_is_dir = isdir (target_directory);
+  dest_is_dir = (n_files > 0 && isdir (target_directory));
 
   if (target_directory_specified)
     {