Initial commit

This commit is contained in:
2026-03-21 12:43:00 -05:00
commit 83bf16823c
438 changed files with 33617 additions and 0 deletions
+385
View File
@@ -0,0 +1,385 @@
diff --git a/Makefile.am b/Makefile.am
index cbbe124..496f993 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,7 +68,7 @@ EXTRA_DIST = xmlto.spec \
doc/xmlif.xml \
xmlto.mak
-GEN_MANPAGE = FORMAT_DIR=$(top_srcdir)/format $(XMLTO_BASH_PATH) ./xmlto --skip-validation -o $(@D) man $<
+GEN_MANPAGE = FORMAT_DIR=$(top_srcdir)/format $(XMLTO_SH_PATH) ./xmlto --skip-validation -o $(@D) man $<
man/man1/xmlto.1: doc/xmlto.xml ; $(GEN_MANPAGE)
man/man1/xmlif.1: doc/xmlif.xml ; $(GEN_MANPAGE)
diff --git a/configure.ac b/configure.ac
index 675dcb8..e5e3b7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,8 +18,11 @@ AC_CHECK_PROG([MKTEMP], [mktemp],, [mktemp])
AC_ARG_VAR([FIND], [Name of the GNU `find' program.])
AC_CHECK_PROG([FIND], [find],, [find] )
-AC_ARG_VAR([XMLTO_BASH_PATH], [Name and path of the GNU `bash' shell.])
-AC_PATH_PROG([XMLTO_BASH_PATH], [bash], [/bin/bash])
+AC_ARG_VAR([XMLTO_SH_PATH], [Name and path of the POSIX `sh' shell.])
+AC_ARG_VAR([XMLTO_BASH_PATH], [Deprecated alias for XMLTO_SH_PATH.])
+AS_IF([test -n "$XMLTO_BASH_PATH" && test -z "$XMLTO_SH_PATH"],
+ [XMLTO_SH_PATH=$XMLTO_BASH_PATH])
+AC_PATH_PROG([XMLTO_SH_PATH], [sh], [/bin/sh])
AC_ARG_VAR([GETOPT], [Name of the `getopt' program (requires longopt support).])
AC_CHECK_PROG([GETOPT], [getopt],, [getopt])
diff --git a/format/docbook/epub b/format/docbook/epub
index 118d605..7acf1d4 100755
--- a/format/docbook/epub
+++ b/format/docbook/epub
@@ -1,4 +1,4 @@
-if [ -z "`type -t $ZIP_PATH`" ]
+if ! command -v "$ZIP_PATH" >/dev/null 2>&1
then
echo >&2 "Missing zip utility at $ZIP_PATH, conversion to epub not possible."
echo >&2 "Exiting !"
@@ -26,7 +26,7 @@ case "$1" in
do
${GCP_PATH:-cp} -R -P -p -- $INPUT_DIR/$CSS_SOURCE $CSS_DEST_DIR/
done
- echo -n "application/epub+zip" > mimetype
+ printf '%s' 'application/epub+zip' > mimetype
EPUB_NAME=$(basename "${XSLT_PROCESSED%.*}").epub
[ -e "$XSLT_PROCESSED" ] && rm "$XSLT_PROCESSED"
${ZIP_PATH} -0Xq $EPUB_NAME mimetype
diff --git a/format/docbook/txt b/format/docbook/txt
index fe42a1f..f356b47 100755
--- a/format/docbook/txt
+++ b/format/docbook/txt
@@ -1,14 +1,14 @@
case "$USE_BACKEND" in
DEFAULT|DBLATEX)
- if [ -n "`type -t $W3M_PATH`" ]
+ if command -v "$W3M_PATH" >/dev/null 2>&1
then
CONVERT="$W3M_PATH"
ARGS="-T text/html -dump"
- elif [ -n "`type -t $LYNX_PATH`" ]
+ elif command -v "$LYNX_PATH" >/dev/null 2>&1
then
CONVERT="$LYNX_PATH"
ARGS="-force_html -dump -nolist -width=72"
- elif [ -n "`type -t $LINKS_PATH`" ]
+ elif command -v "$LINKS_PATH" >/dev/null 2>&1
then
CONVERT="$LINKS_PATH"
ARGS="-dump"
diff --git a/format/fo/dvi b/format/fo/dvi
index 6615048..82794cc 100755
--- a/format/fo/dvi
+++ b/format/fo/dvi
@@ -6,7 +6,7 @@ post-process)
then
echo >&2 "Post-process XSL-FO to DVI"
fi
- if [ -z "`type -t $XMLTEX_PATH`" ]
+ if ! command -v "$XMLTEX_PATH" >/dev/null 2>&1
then
echo >&2 "Can't process, xmltex tool not found at $XMLTEX_PATH."
exit 3
diff --git a/format/fo/pdf b/format/fo/pdf
index 9e586b3..63936eb 100755
--- a/format/fo/pdf
+++ b/format/fo/pdf
@@ -8,7 +8,7 @@ DEFAULT|DBLATEX)
then
echo >&2 "Post-process XSL-FO to PDF"
fi
- if [ -z "`type -t $PDFXMLTEX_PATH`" ]
+ if ! command -v "$PDFXMLTEX_PATH" >/dev/null 2>&1
then
echo >&2 "Can't process, pdfxmltex tool not found at $PDFXMLTEX_PATH."
exit 3
diff --git a/format/xhtml1/txt b/format/xhtml1/txt
index eb1c07a..2c843c2 100755
--- a/format/xhtml1/txt
+++ b/format/xhtml1/txt
@@ -1,14 +1,14 @@
case "$USE_BACKEND" in
DEFAULT|DBLATEX)
- if [ -n "`type -t $W3M_PATH`" ]
+ if command -v "$W3M_PATH" >/dev/null 2>&1
then
CONVERT="$W3M_PATH"
ARGS="-T text/html -dump"
- elif [ -n "`type -t $LYNX_PATH`" ]
+ elif command -v "$LYNX_PATH" >/dev/null 2>&1
then
CONVERT="$LYNX_PATH"
ARGS="-force_html -dump -nolist -width=72"
- elif [ -n "`type -t $LINKS_PATH`" ]
+ elif command -v "$LINKS_PATH" >/dev/null 2>&1
then
CONVERT="$LINKS_PATH"
ARGS="-dump"
diff --git a/xmlif/test/run-test b/xmlif/test/run-test
index a7ddbca..f007928 100755
--- a/xmlif/test/run-test
+++ b/xmlif/test/run-test
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
XMLIF=${top_builddir}/xmlif/xmlif
INPUT=${top_srcdir}/xmlif/test/test.xml
diff --git a/xmlto.in b/xmlto.in
index d5a81a8..f75bfe3 100755
--- a/xmlto.in
+++ b/xmlto.in
@@ -1,4 +1,4 @@
-#!@XMLTO_BASH_PATH@
+#!@XMLTO_SH_PATH@
#
# @PACKAGE@ - apply an XSL stylesheet to an XML document
# Copyright (C) 2001, 2002, 2003 Tim Waugh <twaugh@redhat.com>
@@ -19,7 +19,7 @@
# Utilities that we need that aren't everywhere
FIND=@FIND@ # This must be GNU find (need -maxdepth)
MKTEMP=@MKTEMP@ # See http://www.mktemp.org if missing on your system
-BASH=@XMLTO_BASH_PATH@ # GNU bash, for running the format scripts
+SH=@XMLTO_SH_PATH@ # POSIX sh, for running the format scripts
GETOPT=@GETOPT@ # a getopt that supports --longoptions
TAIL=@TAIL@ # a tail that supports -n (posix)
GREP=@GREP@ # GNU grep, for searching patterns
@@ -78,28 +78,41 @@ EOF
# * Remembers the temporary file's name so it can be deleted on exit
# * If the failure message is empty or missing, exits on failure
make_temp () {
- local dirflag="" prefix="@PACKAGE@"
- [ "$1" = "-d" ] && { dirflag="-d"; shift; }
- [ -n "$1" ] && prefix="@PACKAGE@-$1"
+ make_temp_dirflag=
+ make_temp_prefix="@PACKAGE@"
+ if [ "$1" = "-d" ]
+ then
+ make_temp_dirflag="-d"
+ shift
+ fi
+ if [ -n "$1" ]
+ then
+ make_temp_prefix="@PACKAGE@-$1"
+ fi
- if eval $2='$(${MKTEMP} $dirflag "${TMPDIR:-/tmp}/${prefix}.XXXXXX")'
+ if eval "$2=\$(${MKTEMP} $make_temp_dirflag \"\${TMPDIR:-/tmp}/${make_temp_prefix}.XXXXXX\")"
then
- CLEANFILES="$CLEANFILES ${!2}"
+ eval "make_temp_path=\${$2}"
+ CLEANFILES="$CLEANFILES $make_temp_path"
+ unset make_temp_dirflag make_temp_path make_temp_prefix
return 0
elif [ -z "$3" ]
then
+ unset make_temp_dirflag make_temp_prefix
echo >&2 "mktemp failed!"
exit 2
else
+ unset make_temp_dirflag make_temp_prefix
echo >&2 "mktemp failed. $3"
return 2
fi
}
compute_searchpath () {
- local oldIFS="${IFS}"
+ compute_searchpath_oldIFS="${IFS}"
IFS=":"
- for asearchpath in "$1"; do
+ for asearchpath in $1
+ do
# wrangle relative paths into absolute ones so that the user
# isn't surprised if he does ``--searchpath .''
case "${asearchpath}" in
@@ -111,7 +124,8 @@ compute_searchpath () {
# and only after the first iteration.
XML_SEARCHPATH_SEPARATOR=":"
done
- IFS="${oldIFS}"
+ IFS="${compute_searchpath_oldIFS}"
+ unset compute_searchpath_oldIFS
}
# Allow FORMAT_DIR to be over-ridden, so that we can be
@@ -135,7 +149,7 @@ XSL_MODS=
# List of files to remove after exit
CLEANFILES=
-trap -- 'cd /; [ -z "$CLEANFILES" ] || rm -rf $CLEANFILES' EXIT
+trap 'cd /; [ -z "$CLEANFILES" ] || rm -rf $CLEANFILES' 0
XSLTOPTS=
SEARCHPATH=
@@ -145,13 +159,13 @@ XMLLINT_PATH=@XMLLINT@
XSLTPROC_PATH=@XSLTPROC@
# Try to setup papersize using libpaper first ...
-if type "$PAPERCONF_PATH" >/dev/null 2>&1
+if command -v "$PAPERCONF_PATH" >/dev/null 2>&1
then
papername=`"$PAPERCONF_PATH" -n`
paperheight=`"$PAPERCONF_PATH" -mh | sed 's/ //g'`
paperwidth=`"$PAPERCONF_PATH" -mw | sed 's/ //g'`
- if [ -n "$paperheight" -a -n "$paperwidth" ]
+ if [ -n "$paperheight" ] && [ -n "$paperwidth" ]
then
make_temp xsl papersizemod "Using default paper type." &&
cat << EOF > "$papersizemod"
@@ -176,7 +190,7 @@ EOF
fi
# ... or use magic paper size, based on LC_PAPER
-elif type "$LOCALE_PATH" >/dev/null 2>&1
+elif command -v "$LOCALE_PATH" >/dev/null 2>&1
then
# For paper sizes we know about, specify them.
h=$("$LOCALE_PATH" LC_PAPER 2>/dev/null | head -n 1)
@@ -199,7 +213,7 @@ EOF
fi
# Magic encoding, based on locale
-if type "$LOCALE_PATH" >/dev/null 2>&1
+if command -v "$LOCALE_PATH" >/dev/null 2>&1
then
charmap=$("$LOCALE_PATH" charmap 2>/dev/null)
@@ -249,12 +263,12 @@ XMLTEX_PATH=@XMLTEX@
PDFXMLTEX_PATH=@PDFXMLTEX@
#check if we could use fop/dblatex backend as default(if not, use passivetex)
-if [ x"$USE_BACKEND" = xFOP ] && ! type "$FOP_PATH" >/dev/null 2>&1
+if [ x"$USE_BACKEND" = xFOP ] && ! command -v "$FOP_PATH" >/dev/null 2>&1
then
echo >&2 "@PACKAGE@: Warning: fop not found or not executable."
echo >&2 "@PACKAGE@: Using default backend..."
USE_BACKEND=DEFAULT
-elif type "$FOP_PATH" >/dev/null 2>&1
+elif command -v "$FOP_PATH" >/dev/null 2>&1
then
# we should enable fop.extensions for fop 0_17,0_18 and 0_20*,
# fop1.extensions for the rest
@@ -265,7 +279,7 @@ then
fi
fi
if [ x"$USE_BACKEND" = xDBLATEX ] && \
- ! type "$DBLATEX_PATH" >/dev/null 2>&1
+ ! command -v "$DBLATEX_PATH" >/dev/null 2>&1
then
echo >&2 "@PACKAGE@: Warning: dblatex not found or not executable."
echo >&2 "@PACKAGE@: Using default backend..."
@@ -315,7 +329,7 @@ while [ "$#" -gt "0" ]; do
;;
-o)
OUTPUT_DIR="$2"
- if type -p cygpath >/dev/null; then
+ if command -v cygpath >/dev/null 2>&1; then
OUTPUT_DIR=$(cygpath "$OUTPUT_DIR")
fi
case "$OUTPUT_DIR" in
@@ -362,7 +376,7 @@ while [ "$#" -gt "0" ]; do
shift 2
;;
--noclean)
- trap -- 'cd /; [ -z "$CLEANFILES" ] || echo "$CLEANFILES"' EXIT
+ trap 'cd /; [ -z "$CLEANFILES" ] || echo "$CLEANFILES"' 0
shift
;;
--noautosize)
@@ -371,7 +385,7 @@ while [ "$#" -gt "0" ]; do
;;
--with-fop)
##use fop instead of passivetex where possible
- if ! type "$FOP_PATH" >/dev/null 2>&1
+ if ! command -v "$FOP_PATH" >/dev/null 2>&1
then
echo >&2 Warning: fop not found or not executable.
echo >&2 Using default backend...
@@ -382,7 +396,7 @@ while [ "$#" -gt "0" ]; do
;;
--with-dblatex)
##use dblatex instead of passivetex where possible
- if ! type "$DBLATEX_PATH" >/dev/null 2>&1
+ if ! command -v "$DBLATEX_PATH" >/dev/null 2>&1
then
echo >&2 Warning: dblatex not found or not executable.
echo >&2 Using default backend...
@@ -426,7 +440,7 @@ case "$2" in
*) INPUT_FILE="$PWD/$2" ;;
esac
-if [ -z "$DEST_FORMAT" -o -z "$INPUT_FILE" ]
+if [ -z "$DEST_FORMAT" ] || [ -z "$INPUT_FILE" ]
then
usage
exit 1
@@ -454,7 +468,7 @@ rootel_xpath='concat("{", namespace-uri(/*), "}", local-name(/*))'
rootel="$("$XMLLINT_PATH" --xpath "$rootel_xpath" "$INPUT_FILE" 2>/dev/null)"
-case $(echo $rootel) in
+case $rootel in
"{http://www.w3.org/1999/XSL/Format}root")
SOURCE_FORMAT="fo"
;;
@@ -498,13 +512,13 @@ export PDFXMLTEX_PATH
export USE_BACKEND
if [ -z "$STYLESHEET" ]
then
- STYLESHEET="$(${BASH} "$FORMAT" stylesheet)" || exit 1
+ STYLESHEET="$(${SH} "$FORMAT" stylesheet)" || exit 1
[ "$VERBOSE" -ge 1 ] && echo >&2 "Stylesheet: ${STYLESHEET}"
fi
# We might need to create a temporary stylesheet if there are
# XSL fragments that need adding.
-if [ -n "$XSL_MODS" -a -n "$STYLESHEET" ]
+if [ -n "$XSL_MODS" ] && [ -n "$STYLESHEET" ]
then
REAL_STYLESHEET="$STYLESHEET"
[ "$VERBOSE" -ge 1 ] && echo >&2 "Real stylesheet: ${REAL_STYLESHEET}"
@@ -536,7 +550,7 @@ cd "$XSLT_PROCESSED_DIR"
if [ "$SKIP_VALIDATION" -eq 0 ] && [ "$SOURCE_FORMAT" != "fo" ]
then
#do we have xmllint validation tool?
- if ! type "$XMLLINT_PATH" >/dev/null 2>&1
+ if ! command -v "$XMLLINT_PATH" >/dev/null 2>&1
then
echo >&2 "@PACKAGE@: xmllint validation tool not found or not executable."
echo >&2 "@PACKAGE@: Skipping validation... " \
@@ -572,7 +586,7 @@ XSLTOPTS="${XSLTPARAMS} ${XSLTOPTS}"
if [ "$PROFILE" -eq 1 ] || [ -n "${STYLESHEET}" ]
then
#do we have xsltproc tool?
- if ! type "$XSLTPROC_PATH" >/dev/null 2>&1
+ if ! command -v "$XSLTPROC_PATH" >/dev/null 2>&1
then
echo >&2 "@PACKAGE@: Can't continue, xsltproc tool not found or not executable."
exit 3
@@ -653,6 +667,6 @@ export SEARCHPATH
if [ "$VERBOSE" -gt 2 ]
then
# Extremely verbose
- BASH="${BASH} -x"
+ SH="${SH} -x"
fi
-${BASH} "$FORMAT" post-process || exit 1
+${SH} "$FORMAT" post-process || exit 1
diff --git a/xmlto.spec.in b/xmlto.spec.in
index b9eb4a2..763f76d 100644
--- a/xmlto.spec.in
+++ b/xmlto.spec.in
@@ -57,7 +57,7 @@ xhtml1 source format.
%autosetup -p1
%build
-%configure BASH=/bin/bash
+%configure XMLTO_SH_PATH=/bin/sh
%make_build
%check