-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-usage-msg.sh
executable file
·50 lines (41 loc) · 1.05 KB
/
update-usage-msg.sh
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
#!/bin/sh
#
# Update usage-msg.h from send-echo-request.c comment iff it has
# changed, so that make only rebuilds on actual changes.
set -e
cd "$(dirname "$0")"
test -f send-echo-request.c
cat>usage-msg.h.new<<EOF
#if 0
| DO NOT EDIT THIS FILE.
| It was generated by the $(basename "$0") script
| from the comments in the send-echo-request.c file
| which must end with the first " */" line in the file,
| start with a line beginning with " * Usage: ", and
| each line in between must be " *" or begin with " * ".
#endif
#ifndef USAGE_MSG_H
#define USAGE_MSG_H
#define USAGE_MSG "" \\
EOF
cat send-echo-request.c \
| sed '/^ \*\/$/,$d' \
| sed -n '/^ \* Usage: /,$p' \
| sed -e 's/^ \*$//' -e 's/^ \* //' \
| sed -e 's/^/ "/' -e 's/$/\\n" \\/' \
>> usage-msg.h.new
cat>>usage-msg.h.new<<EOF
""
#endif /* ! USAGE_MSG_H */
EOF
if test -f "usage-msg.h"
then
if cmp -s "usage-msg.h.new" "usage-msg.h"
then
rm "usage-msg.h.new"
else
mv -f "usage-msg.h.new" "usage-msg.h"
fi
else
mv -f "usage-msg.h.new" "usage-msg.h"
fi