File: strip_stx

package info (click to toggle)
stx2any 1.56-2.3
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 748 kB
  • sloc: sh: 312; python: 288; lisp: 137; makefile: 126; sed: 1
file content (55 lines) | stat: -rwxr-xr-x 863 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
# This file is copyright (c) 2004,2005,2006 by Panu Kalliokoski
# and released under the license in ../LICENSE

BASE=.
usage() {
	cat $BASE/messages/strip_stx.usage 1>&2
	exit $1
}

NOT_PROG=d
SEP=`echo | tr '\012' '\001'`
BEG_COMMENT=d
END_COMMENT=d
BEG_STR=
END_STR=

while true; do
	case "$1" in

	-c)	NOT_PROG="s$SEP^$SEP$2$SEP"
		shift
		;;

	-B)	BEG_COMMENT="s$SEP$SEP$2$SEP"
		END_COMMENT="s$SEP$SEP$3$SEP"
		BEG_STR="$2"
		END_STR="$3"
		test "$NOT_PROG" = d && NOT_PROG=b
		shift
		shift
		;;

	--help|-\?) usage 0 ;;
	--version|-V)
		cat $BASE/messages/version.msg
		exit 0
		;;

	*)	break

	esac
	shift
done

ERRORS=

test -n "$BEG_STR" && echo "$BEG_STR"
sed -e "/^{{{$/,/^}}}$/! $NOT_PROG" \
    -e "/^}}}\$/$BEG_COMMENT" \
    -e "/^{{{\$/$END_COMMENT" $@ || ERRORS=yes
test -n "$END_STR" && echo "$END_STR"

test -z "$ERRORS" || usage 1