diff options
author | Werner Koch <[email protected]> | 2019-03-06 19:08:26 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-03-07 09:56:18 +0000 |
commit | 5d73c231e4f2d5994eb3be48b36517e39d66be96 (patch) | |
tree | 4c96a01daddea37593230141bd2e681f58da8f9a | |
parent | gpgtar: Improve error messages. (diff) | |
download | gnupg-5d73c231e4f2d5994eb3be48b36517e39d66be96.tar.gz gnupg-5d73c231e4f2d5994eb3be48b36517e39d66be96.zip |
gpgtar: Make option -C work for archive creation.
* tools/gpgtar-create.c (gpgtar_create): Switch to the -C directory.
--
The -C option is pretty useful given that pattern are always relative
to the current directory. In contrast to GNU tar, the switching is
done only once.
Signed-off-by: Werner Koch <[email protected]>
(cherry picked from commit b3a7a5140784b5a015107b5c5c73b15ae44e71dc)
-rw-r--r-- | doc/tools.texi | 9 | ||||
-rw-r--r-- | tools/gpgtar-create.c | 8 | ||||
-rw-r--r-- | tools/gpgtar.c | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/doc/tools.texi b/doc/tools.texi index 7becf67e2..4e096645e 100644 --- a/doc/tools.texi +++ b/doc/tools.texi @@ -2014,10 +2014,11 @@ Do not actually output the extracted files. @item --directory @var{dir} @itemx -C @var{dir} @opindex directory -Extract the files into the directory @var{dir}. The -default is to take the directory name from -the input filename. If no input filename is known a directory named -@file{GPGARCH} is used. +Extract the files into the directory @var{dir}. The default is to +take the directory name from the input filename. If no input filename +is known a directory named @file{GPGARCH} is used. For tarball +creation, switch to directory @var{dir} before performing any +operations. @item --files-from @var{file} @itemx -T @var{file} diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c index c622a6672..a08601634 100644 --- a/tools/gpgtar-create.c +++ b/tools/gpgtar-create.c @@ -762,6 +762,14 @@ gpgtar_create (char **inpattern, int encrypt, int sign) memset (scanctrl, 0, sizeof *scanctrl); scanctrl->flist_tail = &scanctrl->flist; + if (opt.directory && gnupg_chdir (opt.directory)) + { + err = gpg_error_from_syserror (); + log_error ("chdir to '%s' failed: %s\n", + opt.directory, gpg_strerror (err)); + return err; + } + while (!eof_seen) { char *pat, *p; diff --git a/tools/gpgtar.c b/tools/gpgtar.c index 77001dc91..b33aa6d0f 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -112,7 +112,7 @@ static ARGPARSE_OPTS opts[] = { ARGPARSE_group (302, N_("@\nTar options:\n ")), ARGPARSE_s_s (oDirectory, "directory", - N_("|DIRECTORY|extract files into DIRECTORY")), + N_("|DIRECTORY|change to DIRECTORY first")), ARGPARSE_s_s (oFilesFrom, "files-from", N_("|FILE|get names to create from FILE")), ARGPARSE_s_n (oNull, "null", N_("-T reads null-terminated names")), |