[Bug 15471] New: tar --exclude did not consider --strip-components
bugzilla at busybox.net
bugzilla at busybox.net
Wed Mar 22 06:53:11 UTC 2023
https://bugs.busybox.net/show_bug.cgi?id=15471
Bug ID: 15471
Summary: tar --exclude did not consider --strip-components
Product: Busybox
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P5
Component: Standard Compliance
Assignee: unassigned at busybox.net
Reporter: kkocdko at gmail.com
CC: busybox-cvs at busybox.net
Target Milestone: ---
# tar --exclude did not consider --strip-components
While gnu tar extract a tar file with content `./dir1/dir2/file`, using
`--strip-components 1 --exclude dir2` switches, it will first strip `dir1`,
then match and exclude `dir2`.
However what busybox's tar implementation do is first to match and exclude,
then do `--strip-components 1`.
The test.sh here:
```sh
# tested on debian:11 livecd and fedora:37 livecd
busybox
# clear old files
rm -rf bb-test
# prepair for testing
mkdir -p bb-test/dir1/dir2
cd bb-test
echo file3-content > dir1/dir2/file3
tar -cf a.tar ./dir1
mkdir out-coreut-1 out-busybo-1 out-coreut-2 out-busybo-2
# let's try!
tar -xf a.tar -C out-coreut-1 --strip-components 1 --exclude dir1
busybox tar -xf a.tar -C out-busybo-1 --strip-components 1 --exclude dir1
tar -xf a.tar -C out-coreut-2 --strip-components 1 --exclude dir2
busybox tar -xf a.tar -C out-busybo-2 --strip-components 1 --exclude dir2
# see difference
echo "" && tree out-coreut-1
echo "" && tree out-busybo-1
echo "" && tree out-coreut-2
echo "" && tree out-busybo-2
cd ..
```
And the output on my machine:
```
[kkocdko at klf busybox-report]$ ./test.sh
BusyBox v1.36.0 (2023-01-10 00:00:00 UTC) multi-call binary.
...
out-coreut-1
0 directories, 0 files
out-busybo-1
└── dir1
└── dir2
└── file3
3 directories, 1 file
out-coreut-2
└── dir1
2 directories, 0 files
out-busybo-2
└── dir1
└── dir2
└── file3
3 directories, 1 file
[kkocdko at klf busybox-report]$
```
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list