File: vivym

package info (click to toggle)
vym 2.9.598-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,176 kB
  • sloc: cpp: 44,856; ruby: 2,181; xml: 667; sh: 70; makefile: 17
file content (69 lines) | stat: -rwxr-xr-x 1,308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash

OLD=`pwd`

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for MAP in $*; do
    # Convert rel to abs path
    case $MAP in 
	    /*)  ;;
	    *) MAP=$PWD/$MAP  ;;
    esac
    #echo MAP1=$MAP
    # Create directory
    DIR=`mktemp -d /tmp/vivym.XXXXXX`
    unzip $MAP -d $DIR
    FILE=${MAP##*/}
    EXT=${FILE#*.}
    BASE=${FILE%%.*}

    if ! [ -e $DIR/$BASE.xml ] ; then 
        # echo "Map is renamed, setting BASE=$BASE"
        BASE=$(ls -1 $DIR/*.xml)
        BASE=${BASE##*/}
        BASE=${BASE%%.*}
    fi
    
    #echo MAP=$MAP
    #echo FILE=$FILE
    #echo BASE=$BASE
    #echo EXT=$EXT

    # Count images
    IMGCOUNT=$(ls $DIR/images |wc -l)
    SLIDECOUNT=$(grep "<slide" $DIR/$BASE.xml | wc -l)
    #echo "Found $IMGCOUNT images." 
    #echo "Found $SLIDECOUNT slides."
    #read

    # Create backup for comparison after edit
    BAK=$DIR/$BASE.xml.bak
    cp $DIR/$BASE.xml $BAK

    # Edit
    if [ -z "$EDITOR" ] ; then
        echo "\$EDITOR is not set"
    else
        $EDITOR $DIR/$BASE.xml
    fi

    # Compare
    if cmp $DIR/$BASE.xml $DIR/$BASE.xml.bak  &> /dev/null ; then 
	echo "Map not changed." 
    else  
	# Missing: Zip again
        echo Removing Backup: $BAK
	rm $BAK
	cd $DIR
	zip -r $MAP .

    fi

    #Clean up
    cd $OLD
    rm -rf $DIR
done

IFS=$SAVEIFS