case $# in
0 | 1) echo "Usage : overwriteFile.sh file cmd [arguments]" ;;
esac
file=$1;shift
new=/tmp/overwrte.$$; old=/tmp/overwrte.$$;
trap 'rm -f $new $old;exit 1;' 1 2 15
if PATH=$opath "$@" > $new
then
cp $file $old
trap '' 1 2 15
cp $new $file
else
echo "overwrite failed !"
exit 1
fi
rm -f $new $old
0 | 1) echo "Usage : overwriteFile.sh file cmd [arguments]" ;;
esac
file=$1;shift
new=/tmp/overwrte.$$; old=/tmp/overwrte.$$;
trap 'rm -f $new $old;exit 1;' 1 2 15
if PATH=$opath "$@" > $new
then
cp $file $old
trap '' 1 2 15
cp $new $file
else
echo "overwrite failed !"
exit 1
fi
rm -f $new $old
0 comments:
Post a Comment