File: extract_usage_from_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 (34 lines) | stat: -rwxr-xr-x 611 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
#!/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/extract_usage_from_stx.usage 1>&2
	exit $1
}

case "$1" in
	--help|-\?) usage 0 ;;
	--version|-V)
		cat $BASE/messages/version.msg
		exit 0
		;;
esac

sed -n \
  -e '/^! *SYNOPSIS/,/^!/{' \
  -e '/^$/,/./{' \
  -e 's#^[^ 	!]#Usage: &#' \
  -e '}' \
  -e '/^!/!p' \
  -e '}' \
  -e '/^! *OPTIONS/,/^!/{' \
  -e 's#^! *OPTIONS.*#Options:#p' \
  -e '/^!/d' \
  -e '/^[^ 	].*::$/,/\./{' \
  -e 's#\.  .*#.#' \
  -e 'p' \
  -e '}' \
  -e '}' $@ || usage 1