mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-02 12:57:14 -05:00
Use precise quoting for the shell commands
This commit is contained in:
parent
12b30c198e
commit
840ec7b1c3
5 changed files with 201 additions and 12 deletions
|
|
@ -89,6 +89,36 @@ void memory(void)
|
|||
msg_progress("Using %u MiB of memory for the FileSystem.\n", (unsigned)(malloc_counter_get() / MEBI));
|
||||
}
|
||||
|
||||
void test(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
char buffer[QUOTE_MAX];
|
||||
|
||||
/* special testing code for quoting */
|
||||
if (argc < 2 || strcmp(argv[1], "test") != 0)
|
||||
return;
|
||||
|
||||
for (i = 2; i < argc; ++i) {
|
||||
printf("argv[%d]\n", i);
|
||||
printf("\t#%s#\n", argv[i]);
|
||||
printf("\t#%s#\n", quote(0, argv[i], buffer));
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
assert(strcmp(quote(0, " ", buffer), "\" \"") == 0);
|
||||
assert(strcmp(quote(0, " \" ", buffer), "\" \"\\\"\" \"") == 0);
|
||||
assert(strcmp(quote(0, "&|()<>^", buffer), "^&^|^(^)^<^>^^") == 0);
|
||||
assert(strcmp(quote(0, "&|()<>^ ", buffer), "\"&|()<>^ \"") == 0);
|
||||
#else
|
||||
assert(strcmp(quote(0, ",._+:@%%/-", buffer), ",._+:@%%/-") == 0);
|
||||
assert(strcmp(quote(0, " ", buffer), "\\ ") == 0);
|
||||
#endif
|
||||
|
||||
printf("Everything OK\n");
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* log */
|
||||
|
||||
|
|
@ -472,6 +502,8 @@ int main(int argc, char* argv[])
|
|||
struct tm* tm;
|
||||
int i;
|
||||
|
||||
test(argc, argv);
|
||||
|
||||
lock_init();
|
||||
|
||||
/* defaults */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue