[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"tr -d string1 string2" POSIXLY_CORRECT simplification
From: |
Paul Eggert |
Subject: |
"tr -d string1 string2" POSIXLY_CORRECT simplification |
Date: |
Sat, 05 Jun 2004 10:02:38 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
The coreutils tr source code has an unnecessary special case for
POSIXLY_CORRECT. The SYNOPSIS section for tr
<http://www.opengroup.org/onlinepubs/000095399/utilities/tr.html> says
this:
tr [-c | -C][-s] string1 string2
tr -s [-c | -C] string1
tr -d [-c | -C] string1
tr -ds [-c | -C] string1 string2
None of these alternatives allow "tr -d string1 string2",
so tr is allowed to report an error in that case.
Here is a patch.
2004-06-05 Paul Eggert <address@hidden>
* src/tr.c (main): "tr -d a b" is now a fatal error even if
POSIXLY_CORRECT is set. The POSIX SYNOPSIS does not allow this
option combination.
Index: src/tr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tr.c,v
retrieving revision 1.132
diff -p -u -r1.132 tr.c
--- src/tr.c 2 Jun 2004 08:50:24 -0000 1.132
+++ src/tr.c 5 Jun 2004 16:38:33 -0000
@@ -1739,19 +1739,11 @@ main (int argc, char **argv)
deleting and squeezing repeats"));
/* If --delete is given without --squeeze-repeats, then
- only one string argument may be specified. But POSIX
- says to ignore any string2 in this case, so if POSIXLY_CORRECT
- is set, pretend we never saw string2. But I think
- this deserves a fatal error, so that's the default. */
+ only one string argument may be specified. */
if ((delete && !squeeze_repeats) && non_option_args != 1)
- {
- if (non_option_args == 2 && getenv ("POSIXLY_CORRECT"))
- --non_option_args;
- else
- error (EXIT_FAILURE, 0,
- _("only one string may be given when deleting \
+ error (EXIT_FAILURE, 0,
+ _("only one string may be given when deleting \
without squeezing repeats"));
- }
if (squeeze_repeats && non_option_args == 0)
error (EXIT_FAILURE, 0,
- "tr -d string1 string2" POSIXLY_CORRECT simplification,
Paul Eggert <=