ideaship / ttar Goto Github PK
View Code? Open in Web Editor NEWa simple utility for handling plain text archives
License: Apache License 2.0
a simple utility for handling plain text archives
License: Apache License 2.0
I've created a small ttar
testcase for a problem I ran into while working on this PR: prometheus/node_exporter#871:
#!/bin/sh
echo "*** Create 1st archive"
mkdir -p ttar_testcase/sys/bus/cpu/devices/cpu0
ttar -C ttar_testcase/ -c -f ttar_testcase/sys1.ttar sys
echo
echo "*** Create 2nd archive"
rmdir ttar_testcase/sys/bus/cpu/devices/cpu0
mkdir -p ttar_testcase/sys/devices/system/cpu/cpu0
pushd ttar_testcase/sys/bus/cpu/devices/
ln -s ../../../devices/system/cpu/cpu0 .
popd
ttar -C ttar_testcase/ -c -f ttar_testcase/sys2.ttar sys
echo
echo "*** Remove directory"
rm -rf ttar_testcase/sys/*
echo "*** Extract 1st archive"
ttar -C ttar_testcase/ -x -f ttar_testcase/sys1.ttar
echo
echo "*** Extract 2nd archive over first archive"
ttar -C ttar_testcase/ -x -f ttar_testcase/sys2.ttar
echo
echo "*** Extract 2nd archive over first archive - now with sh -x"
sh -x ttar -C ttar_testcase/ -x -f ttar_testcase/sys2.ttar 2>&1 | tail -n 5
Let's run it:
$ sh ttar_testcase.sh
*** Create 1st archive
/home/knweiss/ttar_testcase
*** Create 2nd archive
/home/knweiss/ttar_testcase/sys/bus/cpu/devices
~/ttar_testcase/sys/bus/cpu/devices ~
~
/home/knweiss/ttar_testcase
*** Remove directory
*** Extract 1st archive
/home/knweiss/ttar_testcase
*** Extract 2nd archive over first archive
/home/knweiss/ttar_testcase
rm: cannot remove 'sys/bus/cpu/devices/cpu0': Is a directory
*** Extract 2nd archive over first archive - now with sh -x
+ [[ Path: sys/bus/cpu/devices/cpu0 =~ ^Path: (.*)$ ]]
+ path=sys/bus/cpu/devices/cpu0
+ '[' -e sys/bus/cpu/devices/cpu0 ']'
+ rm sys/bus/cpu/devices/cpu0
rm: cannot remove 'sys/bus/cpu/devices/cpu0': Is a directory
I.e. ttar
is unable to remove an existing directory. The rm
fails here:
246 if [[ $line =~ ^Path:\ (.*)$ ]]; then
247 path=${BASH_REMATCH[1]}
248 if [ -e "$path" ] || [ -L "$path" ]; then
> 249 rm "$path"
250 fi
689319f added a regression where a file with repeated nul bytes doesn't get properly decoded (a sequence NULLBYTENULLBYTENULLBYTE
should result in \0\0\0
).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.