summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-04-21 09:47:39 +0000
committerJim Meyering <jim@meyering.net>2001-04-21 09:47:39 +0000
commite1e14bdb38fe946d5c6bde8a1f47637dc2e58f77 (patch)
tree0849f715075c6fe2194a41140eae6d7a335b342e /src/ls.c
parent9ea67a3c6fa32955cc7092433087d6802ca2cb15 (diff)
downloadcoreutils-e1e14bdb38fe946d5c6bde8a1f47637dc2e58f77.tar.xz
(main): When given two or more arguments but the only one
that exists is a directory, don't treat it as if it were the only argument. Before, `mkdir d; ls no-dir d 2>/dev/null' would act like `ls d' and produce no output. Now, it prints `d:'.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ls.c b/src/ls.c
index c69012635..7eb50aa64 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -340,16 +340,13 @@ char *program_name;
`files_index' is the number actually in use. */
/* Address of block containing the files that are described. */
-
-static struct fileinfo *files;
+static struct fileinfo *files; /* FIXME: rename this to e.g. cwd_file */
/* Length of block that `files' points to, measured in files. */
-
-static int nfiles;
+static int nfiles; /* FIXME: rename this to e.g. cwd_n_alloc */
/* Index of first unused in `files'. */
-
-static int files_index;
+static int files_index; /* FIXME: rename this to e.g. cwd_n_used */
/* When nonzero, in a color listing, color each symlink name according to the
type of file it points to. Otherwise, color them according to the `ln'
@@ -849,6 +846,7 @@ main (int argc, char **argv)
{
register int i;
register struct pending *thispend;
+ unsigned int n_files;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -896,8 +894,10 @@ main (int argc, char **argv)
clear_files ();
- if (i < argc)
+ n_files = argc - i;
+ if (0 <= n_files)
dir_defaulted = 0;
+
for (; i < argc; i++)
{
gobble_file (argv[i], unknown, 1, "");
@@ -924,7 +924,7 @@ main (int argc, char **argv)
if (pending_dirs)
DIRED_PUTCHAR ('\n');
}
- else if (pending_dirs && pending_dirs->next == 0)
+ else if (n_files <= 1 && pending_dirs && pending_dirs->next == 0)
print_dir_name = 0;
while (pending_dirs)