3 ## $Id: fixscript.in 2805 1999-11-27 07:23:49Z rra $
5 ## Fix interpretor paths and INN variable load paths.
7 ## Scripts shipped with INN always have the invocation path for the
8 ## interpretor on the first line and the command to load INN variable
9 ## settings into the script on the second line. For example, for a Bourne
13 ## . /var/news/lib/innshellvars
15 ## This script takes as input such a script and outputs the same script
16 ## with the first two lines replaced to have the correct path to the
17 ## interpretor and to the INN variable library, as determined by configure.
19 ## If the script is invoked with the -i flag, only fix the interpretor
20 ## path and don't modify the second line of the file to include the
21 ## appropriate innshellvars.
25 PERLPATH='@_PATH_PERL@'
40 if [ -z "$input" ] ; then
41 echo "No input file specified" >&2
46 if [ -z "$output" ] ; then
47 output=`echo "$input" | sed 's/\.in$//'`
49 if [ x"$input" = x"$output" ] ; then
50 echo "No output file specified and input file doesn't end in .in" >&2
54 interpretor=`head -1 "$input"`
55 case "$interpretor" in
58 lib=". $LIBDIR/innshellvars"
61 path=`echo "$interpretor" | sed 's%^#! *[^ ][^ ]*%'"$PERLPATH%"`
62 lib="require '$LIBDIR/innshellvars.pl';"
65 echo "Unknown interpretor $interpretor" >&2
70 echo "#! $path" > "$output"
72 echo "$lib" >> "$output"
73 "$SED" 1,2d "$input" >> "$output"
75 "$SED" 1d "$input" >> "$output"