| 1 |
/* Diagnostics for GNU diffutils |
| 2 |
|
| 3 |
Copyright 2023-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This file is part of GNU DIFF. |
| 6 |
|
| 7 |
This program is free software: you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation, either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 |
|
| 20 |
#include <config.h> |
| 21 |
|
| 22 |
#include "diagnose.h" |
| 23 |
|
| 24 |
#include "gettext.h" |
| 25 |
#include "progname.h" |
| 26 |
#include "quotearg.h" |
| 27 |
|
| 28 |
#include <error.h> |
| 29 |
|
| 30 |
/* In slot N return NAME, quoted for the shell if NAME has unusual characters. |
| 31 |
This is for messages that historically did not quote names, |
| 32 |
where we want to keep the message unchanged for compatibility reasons |
| 33 |
unless the unusual characters might cause confusion. |
| 34 |
Also, POSIX requires that names be unquoted in some cases, |
| 35 |
and we want to respect that for POSIX portable filenames. */ |
| 36 |
char * |
| 37 |
squote (int n, char const *name) |
| 38 |
{ |
| 39 |
return quotearg_n_style (n, shell_escape_quoting_style, name); |
| 40 |
} |
| 41 |
|
| 42 |
/* Issue help for the program. If REASON_MSGID, first issue a |
| 43 |
diagnostic with that reason and with optional operand OPERAND. |
| 44 |
Suggest --help regardless. */ |
| 45 |
void |
| 46 |
try_help (char const *reason_msgid, char const *operand) |
| 47 |
{ |
| 48 |
if (reason_msgid) |
| 49 |
error (0, 0, gettext (reason_msgid), operand); |
| 50 |
error (EXIT_TROUBLE, 0, |
| 51 |
gettext ("Try '%s --help' for more information."), program_name); |
| 52 |
} |