<<< Date Index >>>     <<< Thread Index >>>

source /path/to/rc| (with pipe)



Hey Thomas,

It seems that the sanity checks added sometime in the 1.5 series to
check if it's possible to stat an rc file before proceeding did not take
care of the fact that it could be there's a pipe at the end of it.

Here's a patch against 1.5.6:

--- init.c
+++ init.c
@@ -1366,15 +1366,21 @@ static int source_rc (const char *rcfile
   int line = 0, rc = 0;
   BUFFER token;
   char *linebuf = NULL;
+  char *rrcfile = strdup(rcfile);
   size_t buflen;
   pid_t pid;
   struct stat s;
 
-  if (stat (rcfile, &s) < 0)
+  buflen = strlen(rcfile);
+  if (rcfile[buflen-1] == '|')
+    rrcfile[buflen-1] = '\0';
+  if (stat (rrcfile, &s) < 0)
   {
-    snprintf (err->data, err->dsize, _("%s: stat: %s"), rcfile, strerror 
(errno));
+    snprintf (err->data, err->dsize, _("%s: stat: %s"), rrcfile, strerror 
(errno));
+    free(rrcfile);
     return (-1);
   }
+  free(rrcfile);
   if (!S_ISREG (s.st_mode))
   {
     snprintf (err->data, err->dsize, _("%s: not a regular file"), rcfile);

-- 
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
 and totally illogical, with just a little bit more effort?"
                                -- A. P. J.