Convert writers to lopsub.
[paraslash.git] / man_util.bash
index cb7519c9c6fb0098c6a1f9dc8c39d29c3ead1bee..c98827866c62ce8b0618b1c348a14b3546ff748b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Receivers, filters, writers are called "modules" in this script
+# writers are called "modules" in this script
 print_modhelp()
 {
        local ggo="$1"
@@ -39,30 +39,6 @@ make_help()
                --set-package "para_$1" \
                < "$ggo"
 
-       if [[ "$target" == 'recv' || "$target" == 'audiod' ]]; then
-               for module in $RECEIVERS; do
-                       ggo="$GGO_DIR/${module}_recv.ggo"
-                       [[ ! -f "$ggo" ]] && continue
-                       printf "\nOptions for the $module receiver"
-                       print_modhelp "$ggo"
-               done
-       fi
-       if [[ "$target" == 'filter' || "$target" == 'audiod' ]]; then
-               for module in $FILTERS; do
-                       ggo="$GGO_DIR/${module}_filter.ggo"
-                       [[ ! -f "$ggo" ]] && continue
-                       printf "\nOptions for the $module filter"
-                       print_modhelp "$ggo"
-               done
-       fi
-       if [[ "$target" == 'write' || "$target" == 'audiod' ]]; then
-               for module in $WRITERS; do
-                       ggo="$GGO_DIR/${module}_write.ggo"
-                       [[ ! -f "$ggo" ]] && continue
-                       printf "\nOptions for the $module writer"
-                       print_modhelp "$ggo"
-               done
-       fi
 }
 
 set -u
@@ -90,8 +66,11 @@ target="${target%.*}" # server, audiod, filter, ...
 link="$HELP2MAN_DIR/para_$target"
 
 cl_opts=
+tempfiles=
 for cl in $COMMAND_LISTS; do
-       cl_opts+=" --include $cl"
+       tempfiles+=" $cl.man_util.$$"
+       sed -e '/^\.SH / s/$/]/1' -e '/^\.SH / s/^\.SH /[/1' "$cl" > "$cl.man_util.$$"
+       cl_opts+=" --include $cl.man_util.$$"
 done
 
 # Create a symlink para_$target, pointing to this script. This hack is
@@ -102,7 +81,9 @@ ln -sf "$PWD/$0" "$link"
 # This will call us again twice, with either --help-$target or --version given.
 $HELP2MAN --no-info --help-option "--help-$target" $cl_opts \
        "$link" > "$output_file"
-if (($? != 0)); then
+ret=$?
+rm -f $tempfiles
+if (($ret != 0)); then
        rm -f "$output_file"
        exit 1
 fi