Fix argument handling when running external commands.

* 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
This commit is contained in:
Sergey Poznyakoff
2016-04-14 11:51:38 +03:00
parent 3010818f36
commit 61cd3fd268
2 changed files with 9 additions and 8 deletions

View File

@@ -27,13 +27,14 @@
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);
}