Debian Codegraph @

scripts/restart

raw
1 #! /bin/sh
2 #
3 # restart shell script
4 #
5 if test $# -ne 1; then echo "Usage: $0 checkpoint_file"; exit; fi
6 file="$1"
7
8 if test ! -f "$file"; then echo "$0: $file: File not found"; exit; fi
9 lastTwoEnds=`egrep -n '((;)|(\)\.))[ ]*$' "$file" |
10 sed 's/^\([0-9]*\):.*$/\1/' |
11 tail -2`
12 nFound=`echo $lastTwoEnds | wc -w`
13 if test $nFound -eq 0; then
14 echo "$0: Unable to locate end of tree(s) in file"
15 exit
16 fi
17
18 read first_line
19 echo "$first_line R"
20 cat -
21 # tail -1 "$file"
22
23 if test $nFound -eq 1; then
24 cat "$file"
25 else
26 penultimateEnd=`echo $lastTwoEnds | sed 's/^\([0-9]*\).*$/\1/'`
27 lastStart=`expr $penultimateEnd + 1`
28 tail +$lastStart "$file"
29 fi