]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls: -A now overrides -a
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Mar 2018 21:55:22 +0000 (14:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Mar 2018 22:05:22 +0000 (15:05 -0700)
Problem reported by Karl Berry (Bug#30963).
* NEWS: Mention this.
* src/ls.c (decode_switches): Implement this.
* tests/ls/a-option.sh: New file.
* tests/local.mk (all_tests): Add it.

NEWS
src/ls.c
tests/local.mk
tests/ls/a-option.sh [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 351a0827bca8ef42b48285a5d4211e123502b2ba..207e785b3dfb12f94b02e1f53cd00115df7bc67f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  'ls -aA' is now equivalent to 'ls -A', since -A now overrides -a.
+  [bug introduced in coreutils-5.3.0]
+
   'mv -n A B' no longer suffers from a race condition that can
   overwrite a simultaneously-created B.  This bug fix requires
   platform support for the renameat2 or renameatx_np syscalls, found
index c89a22f68b9ce796cdcde266d22764fa93b15533..bae2c110412b0b9edce5f6a2ca9ac5e3a2a6b795 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -1903,8 +1903,7 @@ decode_switches (int argc, char **argv)
           break;
 
         case 'A':
-          if (ignore_mode == IGNORE_DEFAULT)
-            ignore_mode = IGNORE_DOT_AND_DOTDOT;
+          ignore_mode = IGNORE_DOT_AND_DOTDOT;
           break;
 
         case 'B':
index c798cc83a666dc64ef409fc97923e4ac0caddb1d..e60ea1d1e01e37dafcab4751da9e243d3a806a2a 100644 (file)
@@ -575,6 +575,7 @@ all_tests =                                 \
   tests/ln/sf-1.sh                             \
   tests/ln/slash-decorated-nonexistent-dest.sh \
   tests/ln/target-1.sh                         \
+  tests/ls/a-option.sh                         \
   tests/ls/abmon-align.sh                      \
   tests/ls/block-size.sh                       \
   tests/ls/color-clear-to-eol.sh               \
diff --git a/tests/ls/a-option.sh b/tests/ls/a-option.sh
new file mode 100755 (executable)
index 0000000..4fe1e93
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+# exercise the -a option
+
+# Copyright 2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ls
+
+mkdir d || framework_failure_
+
+ls -aA d >out || framework_failure
+compare /dev/null out || fail=1
+
+Exit $fail