]> git.gag.com Git - debian/tar/commitdiff
Fix argument handling when running external commands.
authorSergey Poznyakoff <gray@gnu.org.ua>
Thu, 14 Apr 2016 08:51:38 +0000 (11:51 +0300)
committerSergey Poznyakoff <gray@gnu.org.ua>
Thu, 14 Apr 2016 08:51:38 +0000 (11:51 +0300)
* src/system.c (xexec): Use sh -c to run the command.  This fixed
bug introduced by 7b5e80396 (tar 1.27)
* doc/tar.texi: Fix checkpoint examples: (1) $TAR_FILENAME
is not available when creating archive and (2) --checkpoint
can't be used as abbreviation of --checkpoint-action

doc/tar.texi
src/system.c

index af4d9d8b6873461c555990177f5738577551c4c3..a8969e088120133e910a37bd5936664876c6fbe4 100644 (file)
@@ -4482,7 +4482,7 @@ command, provided that they are properly escaped, for example:
 
 @smallexample
 @kbd{tar -c -f arc.tar \
-     --checkpoint-action='exec=/sbin/cpoint $TAR_FILENAME'}
+     --checkpoint-action='exec=/sbin/cpoint $TAR_CHECKPOINT'}
 @end smallexample
 
 @noindent
@@ -4737,7 +4737,7 @@ command line of the external command.  For example:
 
 @smallexample
 $ @kbd{tar -x -f archive.tar \
-    --checkpoint=exec='printf "%04d in %32s\r" $TAR_CHECKPOINT $TAR_ARCHIVE'}
+    --checkpoint-action=exec='printf "%04d in %32s\r" $TAR_CHECKPOINT $TAR_ARCHIVE'}
 @end smallexample
 
 @noindent
index e7eede7e345bf5a7f9a6650da2075d41aa195ca0..71a812d5b7a2e01c3e94ee1e6fc2e472e949b1a5 100644 (file)
 static _Noreturn void
 xexec (const char *cmd)
 {
-  struct wordsplit ws;
+  char *argv[4];
 
-  ws.ws_env = (const char **) environ;
-  if (wordsplit (cmd, &ws, (WRDSF_DEFFLAGS | WRDSF_ENV) & ~WRDSF_NOVAR))
-    FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"),
-                 cmd, wordsplit_strerror (&ws)));
-  execvp (ws.ws_wordv[0], ws.ws_wordv);
+  argv[0] = (char *) "/bin/sh";
+  argv[1] = (char *) "-c";
+  argv[2] = (char *) cmd;
+  argv[3] = NULL;
+
+  execv ("/bin/sh", argv);
   exec_fatal (cmd);
 }