From bbc3dd18ff2d758b67b8ea03589dd76f41c25235 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 14 Mar 2009 10:45:48 +0100 Subject: pkg: Don't accidently empty the remote package list --- bin/pkg | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 035cfab..6c1445d 100755 --- a/bin/pkg +++ b/bin/pkg @@ -296,12 +296,18 @@ function list_type_local { } function list_update_remote { + typeset tmpfile=$(mktemp pkglist.XXXXXX) + typeset -i ret=0 export PDIR if [[ $PKG_PROTO == 'ssh' ]] { - ssh $PKG_USER@$PKG_HOST "PDIR='$PDIR' $PKG_PATH/core/include/pkglist $PKG_PATH" > .list-remote + ssh $PKG_USER@$PKG_HOST "PDIR='$PDIR' $PKG_PATH/core/include/pkglist $PKG_PATH" > $tmpfile || ret=$? } elif [[ $PKG_PROTO == 'file' ]] { - $PKG_PATH/core/include/pkglist $PKG_PATH > .list-remote + $PKG_PATH/core/include/pkglist $PKG_PATH > $tmpfile || ret=$? } + if (( ret == 0 )) { + cp $tmpfile .list-remote + } + rm $tmpfile } function list_update_local { -- cgit v1.2.3