snaprep

git mirror of https://ccx.te2000.cz/bzr/snaprep
git clone https://ccx.te2000.cz/git/snaprep
Log | Files | Refs

snap.push.zsh (545B)


      1 #!/bin/zsh
      2 die() {
      3 	print -r - "$@"
      4 	exit 1
      5 }
      6 
      7 if [[ -z $SNAP_SRCS ]]; then
      8 	SNAP_SRCS=$1;shift
      9 fi
     10 SNAP_SRCS=${SNAP_SRCS%%/}
     11 
     12 if [[ -z $SNAP_DST ]]; then
     13 	SNAP_DST=$1;shift
     14 fi
     15 SNAP_DST=${SNAP_DST%%/}
     16 
     17 typeset -A snapshots
     18 for ts in ${(f)"$(snap.list $SNAP_SRCS/)"}; do
     19 	snapshots[$ts]=$SNAP_SRCS/$ts
     20 done
     21 
     22 for ts in ${(f)"$(snap.list $SNAP_DST/)"}; do
     23 	unset "snapshots[$ts]"
     24 done
     25 
     26 export SNAP_SRC SNAP_DST
     27 for SNAP_SRC in $snapshots; do
     28 	if [[ -o xtrace ]]; then
     29 		zsh -x $commands[snap.push.single] "$@"
     30 	else
     31 		snap.push.single "$@"
     32 	fi
     33 done