@@ -96,30 +96,28 @@ host="`echo $host | tr '[[A-Z]]' '[[a-z]]'`"
96
96
if test -f "template/$host"
97
97
then TEMPLATE="$host"
98
98
else
99
- # Next try for an exact match to a .similar entry.
100
- # There shouldn't be multiple matches, but take the last if there are.
101
- GUESS=`grep "^$host=" template/.similar | sed 's/^.*=//' | tail -1`
99
+ # Scan template/.similar for a rule that tells us which template to use.
100
+ # The format of each line of the file is
101
+ # hostnamepattern=templatefilename
102
+ # where the hostnamepattern is evaluated per the rules of expr(1) ---
103
+ # namely, it is a standard regular expression with an implicit ^ at the
104
+ # start. If multiple lines match, we will end up using the last match.
105
+ GUESS=""
106
+ exec 4<template/.similar
107
+ while read LINE <&4
108
+ do
109
+ SIMHOST=`expr "$LINE" : '\(.*\)='`
110
+ MATCH=`expr "$host" : "$SIMHOST"`
111
+ if test "$MATCH" != 0
112
+ then GUESS=`echo "$LINE" | sed 's/^.*=//'`
113
+ fi
114
+ done
115
+ exec 4<&-
102
116
if test "$GUESS"
103
117
then TEMPLATE="$GUESS"
104
118
else
105
- # Next look for a .similar entry that is a prefix of $host.
106
- # If there are multiple matches, take the last one.
107
- exec 4<template/.similar
108
- while read LINE <&4
109
- do
110
- SIMHOST=`expr "$LINE" : '\(.*\)='`
111
- MATCH=`expr "$host" : "$SIMHOST"`
112
- if test "$MATCH" != 0
113
- then GUESS=`echo "$LINE" | sed 's/^.*=//'`
114
- fi
115
- done
116
- exec 4<&-
117
- if test "$GUESS"
118
- then TEMPLATE="$GUESS"
119
- else
120
- # Last chance ... maybe uname -s will match an entry.
121
- TEMPLATE=`uname -s | tr '[[A-Z]]' '[[a-z]]'`
122
- fi
119
+ # Last chance ... maybe uname -s will match an entry.
120
+ TEMPLATE=`uname -s | tr '[[A-Z]]' '[[a-z]]'`
123
121
fi
124
122
fi
125
123
])
@@ -130,7 +128,7 @@ if test ! -f "template/$TEMPLATE"; then
130
128
echo ""
131
129
echo "$TEMPLATE does not exist"
132
130
echo ""
133
- echo "Available Templates (set using --with-template):"
131
+ echo "Available Templates (select one using --with-template):"
134
132
echo ""
135
133
ls template
136
134
echo ""
0 commit comments