File: fixscript.in

package info (click to toggle)
inn2 2.4.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,912 kB
  • ctags: 7,860
  • sloc: ansic: 85,104; perl: 11,427; sh: 9,863; makefile: 2,498; yacc: 1,563; python: 298; lex: 252; tcl: 7
file content (77 lines) | stat: -rw-r--r-- 1,892 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
70
71
72
73
74
75
76
77
#! @_PATH_SH@

##  $Id: fixscript.in 2805 1999-11-27 07:23:49Z rra $
##
##  Fix interpretor paths and INN variable load paths.
##
##  Scripts shipped with INN always have the invocation path for the
##  interpretor on the first line and the command to load INN variable
##  settings into the script on the second line.  For example, for a Bourne
##  shell script:
##
##      #!/bin/sh
##      . /var/news/lib/innshellvars
##
##  This script takes as input such a script and outputs the same script
##  with the first two lines replaced to have the correct path to the
##  interpretor and to the INN variable library, as determined by configure.
##
##  If the script is invoked with the -i flag, only fix the interpretor
##  path and don't modify the second line of the file to include the
##  appropriate innshellvars.

SED='@_PATH_SED@'

PERLPATH='@_PATH_PERL@'
SHPATH='@_PATH_SH@'
LIBDIR='@LIBDIR@'

options=true
addlib=true
while $options ; do
    case X"$1" in
    X-i) addlib=false  ;;
    *)   options=false ;;
    esac
    $options && shift
done

input="$1"
if [ -z "$input" ] ; then
    echo "No input file specified" >&2
    exit 1
fi

output="$2"
if [ -z "$output" ] ; then
    output=`echo "$input" | sed 's/\.in$//'`
fi
if [ x"$input" = x"$output" ] ; then
    echo "No output file specified and input file doesn't end in .in" >&2
    exit 1
fi

interpretor=`head -1 "$input"`
case "$interpretor" in
*/sh|*SH*)
    path="$SHPATH"
    lib=". $LIBDIR/innshellvars"
    ;;
*/perl*|*PERL*)
    path=`echo "$interpretor" | sed 's%^#! *[^ ][^ ]*%'"$PERLPATH%"`
    lib="require '$LIBDIR/innshellvars.pl';"
    ;;
*)
    echo "Unknown interpretor $interpretor" >&2
    exit 1
    ;;
esac

echo "#! $path"          >  "$output"
if $addlib ; then
    echo "$lib"          >> "$output"
    "$SED" 1,2d "$input" >> "$output"
else
    "$SED" 1d "$input"   >> "$output"
fi
chmod 755 "$output"