summaryrefslogtreecommitdiff
path: root/src/md5sum.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-01 18:53:26 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:14 +0000
commit08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch)
tree63d021e305cd93bea445f9484fe8b3446dda2c3d /src/md5sum.c
parent1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff)
downloadcoreutils-08e8fd7e38f2dae7c69c54eb22d508b6517e66e5.tar.xz
all: avoid quoting file names when possible
Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly.
Diffstat (limited to 'src/md5sum.c')
-rw-r--r--src/md5sum.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/md5sum.c b/src/md5sum.c
index 16163cc9e..5d4b958ee 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -37,7 +37,6 @@
#endif
#include "error.h"
#include "fadvise.h"
-#include "quote.h"
#include "stdio--.h"
#include "xfreopen.h"
@@ -483,7 +482,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result)
fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r"));
if (fp == NULL)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
}
@@ -493,7 +492,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result)
err = DIGEST_STREAM (fp, bin_result);
if (err)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
if (fp != stdin)
fclose (fp);
return false;
@@ -501,7 +500,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result)
if (!is_stdin && fclose (fp) != 0)
{
- error (0, errno, "%s", quote (filename));
+ error (0, errno, "%s", quotef (filename));
return false;
}
@@ -536,7 +535,7 @@ digest_check (const char *checkfile_name)
checkfile_stream = fopen (checkfile_name, "r");
if (checkfile_stream == NULL)
{
- error (0, errno, "%s", quote (checkfile_name));
+ error (0, errno, "%s", quotef (checkfile_name));
return false;
}
}
@@ -554,7 +553,7 @@ digest_check (const char *checkfile_name)
++line_number;
if (line_number == 0)
error (EXIT_FAILURE, 0, _("%s: too many checksum lines"),
- quote (checkfile_name));
+ quotef (checkfile_name));
line_length = getline (&line, &line_chars_allocated, checkfile_stream);
if (line_length <= 0)
@@ -579,7 +578,7 @@ digest_check (const char *checkfile_name)
error (0, 0,
_("%s: %" PRIuMAX
": improperly formatted %s checksum line"),
- quote (checkfile_name), line_number,
+ quotef (checkfile_name), line_number,
DIGEST_TYPE_STRING);
}
@@ -651,13 +650,13 @@ digest_check (const char *checkfile_name)
if (ferror (checkfile_stream))
{
- error (0, 0, _("%s: read error"), quote (checkfile_name));
+ error (0, 0, _("%s: read error"), quotef (checkfile_name));
return false;
}
if (!is_stdin && fclose (checkfile_stream) != 0)
{
- error (0, errno, "%s", quote (checkfile_name));
+ error (0, errno, "%s", quotef (checkfile_name));
return false;
}
@@ -665,7 +664,7 @@ digest_check (const char *checkfile_name)
{
/* Warn if no tests are found. */
error (0, 0, _("%s: no properly formatted %s checksum lines found"),
- quote (checkfile_name), DIGEST_TYPE_STRING);
+ quotef (checkfile_name), DIGEST_TYPE_STRING);
}
else
{