posixoptions.7: Fix legacy functions list (s/getcwd/getwd/)
[man-pages.git] / scripts / FIXME_list.sh
blob59ba3c0cb9b0b9a426cb67e89ac255777a01372d
1 #!/bin/sh
3 # FIXME_list.sh
5 # Display FIXME segments from man-pages source files
7 # (C) Copyright 2007 & 2013, Michael Kerrisk
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details
17 # (http://www.gnu.org/licenses/gpl-2.0.html).
19 ######################################################################
21 # (C) Copyright 2006 & 2013, Michael Kerrisk
22 # This program is free software; you can redistribute it and/or
23 # modify it under the terms of the GNU General Public License
24 # as published by the Free Software Foundation; either version 2
25 # of the License, or (at your option) any later version.
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details
31 # (http://www.gnu.org/licenses/gpl-2.0.html).
35 show_all="n"
36 while getopts "a" optname; do
37 case "$optname" in
39 a) # "all"
40 # Even show FIXMEs that aren't generally interesting. (Typically
41 # these FIXMEs are notes to the maintainer to reverify something
42 # at a future date.)
44 show_all="y"
47 *) echo "Unknown option: $OPTARG"
48 exit 1
51 esac
52 done
54 shift $(( $OPTIND - 1 ))
56 if test $# -eq 0; then
57 echo "Usage: $0 [-a] pathname..." 1>&2
58 exit 1;
61 for dir in "$@"; do
62 for page in $(find "$dir" -type f -name '*.[1-9]' \
63 -exec grep -l FIXME {} \; | sort)
65 cat "$page" | awk -v SHOW_ALL=$show_all -v PAGE_NAME="$page" \
67 BEGIN {
68 page_FIXME_cnt = 0;
71 /FIXME/ {
73 # /.\" FIXME . / ==> do not display this FIXME, unless
74 # -a command-line option was supplied
76 if ($0 ~ /^\.\\" FIXME \./ )
77 FIXME_type = "hidden"
78 else if ($0 ~ /^\.\\" FIXME *\?/ )
79 FIXME_type = "question"
80 else
81 FIXME_type = "normal";
82 if (FIXME_type == "normal" || SHOW_ALL == "y") {
83 if (page_FIXME_cnt == 0) {
84 print "==========";
85 print PAGE_NAME;
87 page_FIXME_cnt++;
89 finished = 0;
90 do {
91 print $0;
93 # Implicit end of FIXME is end-of-file or a line
94 # that is not a comment
96 if (getline == 0)
97 finished = 1;
99 if (!($0 ~ /^.\\"/))
100 finished = 1;
102 # /.\" .$/ ==> Explicit end of FIXME
104 if ($0 ~ /^.\\" \.$/)
105 finished = 1;
106 } while (!finished);
108 print "";
112 done | sed -e 's/^\.\\"/ /' | sed -e 's/ *$//' | cat -s
113 done