1 diff -urN a2ps-4.13.orig/src/select.c a2ps-4.13/src/select.c
2 --- a2ps-4.13.orig/src/select.c 2004-12-13 14:32:29.582879216 +0100
3 +++ a2ps-4.13/src/select.c 2004-12-13 14:33:42.773752512 +0100
8 +/* escapes the name of a file so that the shell groks it in 'single' q.marks.
9 + The resulting pointer has to be free()ed when not longer used. */
11 +shell_escape(const char *fn)
15 + char *retval, *outp;
17 + for(inp = fn; *inp; ++inp)
20 + case '\'': len += 4; break;
21 + default: len += 1; break;
24 + outp = retval = malloc(len + 1);
26 + return NULL; /* perhaps one should do better error handling here */
27 + for(inp = fn; *inp; ++inp)
30 + case '\'': *outp++ = '\''; *outp++ = '\\'; *outp++ = '\'', *outp++ = '\''; break;
31 + default: *outp++ = *inp; break;
38 /* What says file about the type of a file (result is malloc'd). NULL
39 if could not be run. */
42 if (IS_EMPTY (job->file_command))
45 + filename = shell_escape(filename);
46 + if(filename == NULL)
48 /* Call file(1) with the correct option */
49 - command = ALLOCA (char, (2
50 + command = ALLOCA (char, (4
51 + strlen (job->file_command)
52 + ustrlen (filename)));
53 - sprintf (command, "%s %s", job->file_command, (const char *) filename);
54 + sprintf (command, "%s '%s'", job->file_command, (const char *) filename);
56 message (msg_tool, (stderr, "Reading pipe: `%s'\n", command));
57 file_out = popen (command, "r");