SHA256
1
0
forked from pool/file
file/file-5.24-nitpick.dif

59 lines
2.1 KiB
Plaintext

---
src/file.c | 8 ++++++++
src/file_opts.h | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
--- src/file.c
+++ src/file.c 2018-10-22 07:56:59.735038350 +0000
@@ -108,10 +108,12 @@ private const struct option long_options
#define OPT_MIME_ENCODING 5
#define OPT(shortname, longname, opt, def, doc) \
{longname, opt, NULL, shortname},
+#define OPT_POSIX OPT
#define OPT_LONGONLY(longname, opt, def, doc, id) \
{longname, opt, NULL, id},
#include "file_opts.h"
#undef OPT
+#undef OPT_POSIX
#undef OPT_LONGONLY
{0, 0, NULL, 0}
};
@@ -647,6 +649,7 @@ docprint(const char *opts, int def)
private void
help(void)
{
+ const unsigned long posix = (unsigned long)getenv("POSIXLY_CORRECT");
(void)fputs(
"Usage: file [OPTION...] [FILE...]\n"
"Determine type of FILEs.\n"
@@ -654,11 +657,16 @@ help(void)
#define OPT(shortname, longname, opt, def, doc) \
fprintf(stdout, " -%c, --" longname, shortname), \
docprint(doc, def);
+#define OPT_POSIX(shortname, longname, opt, def, doc) \
+ fprintf(stdout, " -%c, --" longname "%s", shortname, \
+ (shortname == 'L') ? (posix ? " (default)" : "") : (posix ? "" : " (default)")), \
+ docprint(doc, def);
#define OPT_LONGONLY(longname, opt, def, doc, id) \
fprintf(stdout, " --" longname), \
docprint(doc, def);
#include "file_opts.h"
#undef OPT
+#undef OPT_POSIX
#undef OPT_LONGONLY
fprintf(stdout, "\nReport bugs to https://bugs.astron.com/\n");
exit(EXIT_SUCCESS);
--- src/file_opts.h
+++ src/file_opts.h 2018-10-22 07:55:03.281221021 +0000
@@ -36,8 +36,8 @@ OPT_LONGONLY("mime-encoding", 0, 0, "
OPT('k', "keep-going", 0, 0, " don't stop at the first match\n")
OPT('l', "list", 0, 0, " list magic strength\n")
#ifdef S_IFLNK
-OPT('L', "dereference", 0, 1, " follow symlinks")
-OPT('h', "no-dereference", 0, 2, " don't follow symlinks")
+OPT_POSIX('L', "dereference", 0, 1, " follow symlinks")
+OPT_POSIX('h', "no-dereference", 0, 2, " don't follow symlinks")
#endif
OPT('n', "no-buffer", 0, 0, " do not buffer output\n")
OPT('N', "no-pad", 0, 0, " do not pad output\n")