aboutsummaryrefslogtreecommitdiffstats
path: root/ports-mgmt/genpatch/files/portfix.in
blob: 06538310c310bd45361bf90749214643a889ff1e (plain) (blame)
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
#!/bin/sh
#
# usage: portfix origfile
#
# This is a wrapper.  It runs consecutively:
#   1. dupe XXX
#   2. <editor> XXX
#   3. genpatch XXX 
#
# If PORTEDITOR is defined in the environment, that program will be
# used instead of the EDITOR env. variable.  If neither are defined
# it will fall back to vi.


if [ $# -eq 1 ]; then
    old=${1}
    if [ ! -f ${old} ]; then
        echo "${0}: '${old}' does not exist! aborting..."
        exit 1;
    fi
else
    echo "${0}: need exactly one argument"
    echo "${0} <path/to/original/file>"
    exit 1;
fi

if [ -n "${PORTEDITOR}" ]; then
    MYPORTEDITOR=${PORTEDITOR}
elif [ -n "${EDITOR}" ]; then
    MYPORTEDITOR=${EDITOR}
else
    MYPORTEDITOR=/usr/bin/vi
fi

%%PREFIX%%/bin/dupe ${old}
${MYPORTEDITOR} ${old}
if [ $? -eq 0 ]; then
    %%PREFIX%%/bin/genpatch ${old}
fi