Some tweak & fixes on interface definitions.
[screen-lua.git] / src / etc / newsyntax38
blobb22850d1d09ca23e5552b16f815e65bd492071ce
1 #! /bin/sh
3 # newsyntax38 -- update a screenrc file from 3.3 to 3.8 syntax
5 # Please bring your scripts up to syntax level 3.3 before running this script.
6 # Please check all comments after running this script and watch out
7 # for funny passages.
9 # * aka and shellaka are replaced by title and shelltitle.
11 # * Pairs of termcap and terminfo commands are folded into a single
12 # termcapinfo command where possible.
14 # * trailing blanks are zapped. Unintentionally.
16 # 12.10.95, jnweiger, use at your own risk.
18 if [ $# != 1 ]; then
19 echo "usage $0 screenrcfile"
20 echo ""
21 echo "The named file will be updated in place to the syntax of screen 3.8"
22 echo "A backup copy will be written to <screenrcfile>.bak"
23 exit 1;
26 #Ultrix 4.2 /bin/sh does not handle "read a < $1"
27 #Dean Gaudet <dgaudet@watdragon.uwaterloo.ca>
28 exec < $1
29 read a
31 if [ "$a" = "#3.8" ]; then
32 echo "$1 already updated"
33 exit 0
36 rm -f $1.old $1.dups
38 cp $1 $1.old
39 echo "#3.8" > $1
40 echo "# Do not remove the above line. This screen rc file was updated" >> $1
41 echo "# by the newsyntax script." >> $1
43 # termcap and terminfo lines can only be folded when there is no parameter
44 # expansion in the codes. Parameters are denoted differently in
45 # termcap and termcap syntax. Everything else is identical, I assume.
46 # Thus codes not containing '%' can be savely folded.
48 sed < $1.old > $1.dups \
49 -e 's/^\([ #]*\)aka/\1title/' \
50 -e 's/^\([ #]*\)shellaka/\1shelltitle/' \
51 -e 's/^\([ #]*\)termcap[ ][ ]*\([^%]*$\)/\1termcapinfo \2/' \
52 -e 's/^\([ #]*\)terminfo[ ][ ]*\([^%]*$\)/\1termcapinfo \2/' \
53 -e 's/\\/\\\\/g'
55 # Oh, my bourne shell seems to gobble backslashes while reading.
56 # Thus the sed above duplicates them in advance.
57 # Hope this is not just another silly bash featureism.
58 # It still zaps trailing blanks. I do not know why. But that is nice.
60 exec < $1.dups
61 while read a ; do
62 if [ "$a" = "$b" ]; then
63 case "$a" in
64 *termcapinfo*) continue ;;
65 esac
67 echo "$a" >> $1
68 b="$a"
69 done
71 rm -f $1.dups