summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-10-17 07:39:20 +0000
committerJim Meyering <jim@meyering.net>1999-10-17 07:39:20 +0000
commita374a307c500f2669166a753136c242ef5674f59 (patch)
tree47fe07cac44d026d239ee71f4a4589a5ec3a8d75 /src
parentb221905959bed78f8c7f3a4dcba5ba4ea23b6dde (diff)
downloadcoreutils-a374a307c500f2669166a753136c242ef5674f59.tar.xz
don't compute isdir() of -- or an option string
Diffstat (limited to 'src')
-rw-r--r--src/mv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mv.c b/src/mv.c
index 291b531f0..41d3a9250 100644
--- 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)
{