# 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@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@klf busybox-report]$ ```
I'm sorry, the test script is broken.