summaryrefslogtreecommitdiff
path: root/lib/argmatch.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-01-02 20:35:06 +0000
committerJim Meyering <jim@meyering.net>1999-01-02 20:35:06 +0000
commit7b36cfca743bbc31f5e3234ba9d62f1ce3bdbc88 (patch)
treec948fcb3f838ccb1f4ae341a24a891d09f0dc871 /lib/argmatch.c
parent75b8fb688fa4e3fa82025c6597be9efb390d0b35 (diff)
downloadcoreutils-7b36cfca743bbc31f5e3234ba9d62f1ce3bdbc88.tar.xz
(argmatch_invalid): Remove double quotes from the
offending quoted argument before using it in explanatory diagnostic. Use a single fprintf stmt.
Diffstat (limited to 'lib/argmatch.c')
-rw-r--r--lib/argmatch.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/argmatch.c b/lib/argmatch.c
index 4e879691f..517c6e529 100644
--- a/lib/argmatch.c
+++ b/lib/argmatch.c
@@ -130,6 +130,8 @@ void
argmatch_invalid (const char *kind, const char *value, int problem)
{
enum quoting_style saved_quoting_style;
+ char const *format;
+ char *quoted_arg;
/* Make sure to have a good quoting style to report errors.
literal is insane here. */
@@ -137,14 +139,17 @@ argmatch_invalid (const char *kind, const char *value, int problem)
set_quoting_style (NULL, ARGMATCH_QUOTING_STYLE);
/* There is an error */
- fprintf (stderr, "%s: ", program_name);
- if (problem == -1)
- fprintf (stderr, _("invalid argument %s for `%s'"),
- quotearg (value), kind);
- else /* Assume -2. */
- fprintf (stderr, _("ambiguous argument %s for `%s'"),
- quotearg (value), kind);
- putc ('\n', stderr);
+ quoted_arg = quotearg (value);
+
+ /* Skip over the first quote character, and overwrite the last one. */
+ ++quoted_arg;
+ quoted_arg[strlen (quoted_arg) - 1] = '\0';
+
+ format = (problem == -1
+ ? _("%s: invalid argument `%s' for `%s'\n")
+ : _("%s: ambiguous argument `%s' for `%s'\n"));
+
+ fprintf (stderr, format, program_name, quoted_arg, kind);
set_quoting_style (NULL, saved_quoting_style);
}