Git Product home page Git Product logo

ttar's People

Contributors

discordianfish avatar grobie avatar ideaship avatar knweiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ttar's Issues

ttar cannot remove existing directory

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.