blob: d62d2d2564321eafe6ea7058770309867d2dfd90 (
plain)
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
|
#! /bin/sh
#
# Copyright (c) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# weblogconv: convert weblog.conf files to posix regex
#
# only needed on Linux
progname=$0
if [ $# -gt 0 -a "$1" = "-?" ]; then
echo "Usage: $progname infile [outfile]"
exit 0
fi
if [ $# -gt 2 ]; then
echo "$progname: Too many arguments."
exit 1
fi
if [ $# -lt 1 ] ; then
infile=""
else
infile=$1
fi
if [ $# -lt 2 ]; then
outfile=""
else
outfile="> $2"
fi
if [ -n "$infile" -a ! -r "$infile" ]; then
echo "$progname: cannot read $infile"
exit 1
fi
sed \
-e '/)\$[01]/!s/^regex[ \t][ \t]*\([^ \t][^ \t]*\)[ \t][ \t]*/regex_posix \1 - /' \
-e 's/^regex[ \t][ \t]*\([^ \t][^ \t]*\)[ \t][ \t]*\(.*$0.*$1.*\)/regex_posix \1 method,size \2/' \
-e 's/^regex[ \t][ \t]*\([^ \t][^ \t]*\)[ \t][ \t]*\(.*$1.*$0.*\)/regex_posix \1 size,method \2/' \
-e 's/)$0/)/g' \
-e 's/)$1/)/g' $infile | eval cat $outfile
exit 0
|