aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/tar.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/tar.c')
-rw-r--r--toys/posix/tar.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/posix/tar.c b/toys/posix/tar.c
index 16e4e49c..9642fbe6 100644
--- a/toys/posix/tar.c
+++ b/toys/posix/tar.c
@@ -17,7 +17,7 @@
* Why --exclude pattern but no --include? tar cvzf a.tgz dir --include '*.txt'
*
-USE_TAR(NEWTOY(tar, "&(restrict)(full-time)(no-recursion)(numeric-owner)(no-same-permissions)(overwrite)(exclude)*(mode):(mtime):(group):(owner):(to-command):o(no-same-owner)p(same-permissions)k(keep-old)c(create)|h(dereference)x(extract)|t(list)|v(verbose)J(xz)j(bzip2)z(gzip)S(sparse)O(to-stdout)m(touch)X(exclude-from)*T(files-from)*C(directory):f(file):a[!txc][!jzJa]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_TAR(NEWTOY(tar, "&(restrict)(full-time)(no-recursion)(numeric-owner)(no-same-permissions)(overwrite)(exclude)*(mode):(mtime):(group):(owner):(to-command):o(no-same-owner)p(same-permissions)k(keep-old)c(create)|h(dereference)x(extract)|t(list)|v(verbose)J(xz)j(bzip2)z(gzip)S(sparse)O(to-stdout)P(absolute-names)m(touch)X(exclude-from)*T(files-from)*C(directory):f(file):a[!txc][!jzJa]", TOYFLAG_USR|TOYFLAG_BIN))
config TAR
bool "tar"
@@ -189,7 +189,7 @@ static int add_to_tar(struct dirtree *node)
}
i = 1;
- name = dirtree_path(node, &i);
+ name = hname = dirtree_path(node, &i);
// exclusion defaults to --no-anchored and --wildcards-match-slash
for (lnk = name; *lnk;) {
@@ -202,7 +202,7 @@ static int add_to_tar(struct dirtree *node)
if (S_ISDIR(st->st_mode) && name[i-1] != '/') strcat(name, "/");
// remove leading / and any .. entries from saved name
- for (hname = name; *hname == '/'; hname++);
+ if (!FLAG(P)) while (*hname == '/') hname++;
for (lnk = hname;;) {
if (!(lnk = strstr(lnk, ".."))) break;
if (lnk == hname || lnk[-1] == '/') {