#! /bin/sh
#
# mkinstall - make the INSTALL file from the `Installing Bash' node of the
#	      texinfo manual
#

NODE="Installing Bash"
SUBNODE="Basic Installation"
TEXI=bashref.texi
TMPINFO=temp.info
TMPOUT=INSTALL.tmp

OUT=${1:-INSTALL}

trap 'rm -f $TMPOUT $TMPINFO $OUT; trap '' 0; exit 1' 1 2 3 6 15
#trap 'rm -f $TMPOUT $TMPINFO' 0

# create an info file without paragraph indentation
makeinfo --no-split -I../lib/readline/doc --paragraph-indent 0 -o $TMPINFO $TEXI

# write out the text from the `Installing Bash' node to INSTALL.tmp
info --file $TMPINFO --node "$NODE" --subnodes --output $TMPOUT

exit 0
# remove the info traversal information and the initial menu, and squeeze
# out multiple consecutive blank lines like `cat -s'
awk 'BEGIN { printline = 0; newlines = 0; }

/^File: '$TMPINFO'/	{ next; }

/^'"$SUBNODE"'/	{ printline = 1; }

/^$/			{ if (printline) newlines = 1; next; }

/$/			{ if (printline) {
				if (newlines) {
					printf "\n";
					newlines = 0;
				}
				print $0;
			  }
			}' < $TMPOUT > $OUT

exit 0
