Add a cpio emulation script based on GNU tar.

This commit is contained in:
Johannes Sixt
2007-01-08 11:45:20 +01:00
parent 4b5821b21b
commit aa0dba9443
2 changed files with 47 additions and 1 deletions

View File

@@ -177,7 +177,8 @@ SCRIPT_SH = \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
git-merge-resolve.sh git-merge-ours.sh \
git-lost-found.sh git-quiltimport.sh
git-lost-found.sh git-quiltimport.sh \
cpio.sh
SCRIPT_PERL = \
git-add--interactive.perl \

45
cpio.sh Normal file
View File

@@ -0,0 +1,45 @@
#!/bin/sh
#
# Emulates some cpio behavior using GNU tar
die() {
echo >&2 "$@"
exit 1
}
tr0=cat
while test $# -gt 0; do
case "$1" in
-0) tr0="tr '\0' ' '";;
-o) mode=o;;
-iuv) ;;
-pumd|-pumdl)
mode=p
dir="$2"
shift
;;
*) die "cpio emulation supports only -0, -o, -iuv, -pumdl";;
esac
shift
done
case $mode in
o)
files=.cpiofiles$$
$tr0 > $files
tar --create --file=- --files-from=$files --exclude=$files
rc=$?
rm -f $files
exit $rc
;;
p)
files=.cpiofiles$$
$tr0 > $files
tar --create --file=- --files-from=$files --exclude=$files |
tar --extract --directory="$dir" --file=-
rm -f $files
;;
*)
tar xvf - || exit
esac