summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@src.gnome.org>2007-05-08 19:55:55 +0000
committerShaun McCance <shaunm@src.gnome.org>2007-05-08 19:55:55 +0000
commitadff34d7c30aa86e5e6728b10f11d8a79d9bda41 (patch)
tree08f5955cff4fd2ca98cf5a1f53249a99cbee255a
parent4879aee77c51f76289e2624ce00f9a162f4866dd (diff)
downloadgnome-doc-utils-adff34d7c30aa86e5e6728b10f11d8a79d9bda41.tar.gz
- (backporting fixes from trunk) - Use = instead of == to test equality -
* tools/gnome-doc-tool.in: - (backporting fixes from trunk) - Use = instead of == to test equality - Explicitly check for an empty command to avoid shift error - Removed bsh-only parameter substitutions and function syntax, #436824 - Fixed global variable polution that caused directories to be forgotten, #436950 svn path=/branches/gnome-2-18/; revision=939
-rw-r--r--ChangeLog9
-rwxr-xr-xtools/gnome-doc-tool.in57
2 files changed, 37 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index aef3be1..bf94cb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-05-08 Shaun McCance <shaunm@gnome.org>
+
+ * tools/gnome-doc-tool.in:
+ - (backporting fixes from trunk)
+ - Use = instead of == to test equality
+ - Explicitly check for an empty command to avoid shift error
+ - Removed bsh-only parameter substitutions and function syntax, #436824
+ - Fixed global variable polution that caused directories to be forgotten, #436950
+
2007-04-09 Shaun McCance <shaunm@gnome.org>
* configure.in:
diff --git a/tools/gnome-doc-tool.in b/tools/gnome-doc-tool.in
index 6c00a37..add1fbc 100755
--- a/tools/gnome-doc-tool.in
+++ b/tools/gnome-doc-tool.in
@@ -33,12 +33,12 @@ datadir=@datadir@
pkgdatadir=@datadir@/gnome-doc-utils
xsltdir=@datadir@/xml/gnome/xslt
-function error {
+error() {
echo "$progname: $1" 1>&2;
exit 1;
}
-function print_help {
+print_help() {
cat <<EOF
Usage: $progname <COMMAND> [OPTIONS] FILE
Process a documentation file.
@@ -49,7 +49,7 @@ COMMAND is one of:
EOF
}
-function print_help_html {
+print_help_html() {
cat <<EOF
Usage: $progname html [OPTIONS] FILE
Convert FILE into HTML.
@@ -76,21 +76,21 @@ Miscellaneous:
-h, --help display this help and exit
EOF
}
-function echo_verbose {
- if [ "x$doc_verbose" == "x1" ]; then echo $1; fi
+echo_verbose() {
+ if [ "x$doc_verbose" = "x1" ]; then echo $1; fi
}
-function mkdir_p {
- dir='';
+mkdir_p() {
+ __dir__='';
echo $1 | sed -e 's/\//\n/g' | while read d; do
- dir="$dir$d/"
- if [ ! -d "$dir" ]; then
- echo_verbose "mkdir \"$dir\""
- mkdir "$dir"
+ __dir__="$__dir__$d/"
+ if [ ! -d "$__dir__" ]; then
+ echo_verbose "mkdir \"$__dir__\""
+ mkdir "$__dir__"
fi
done;
}
-function DO_html {
+DO_html() {
longopts='
-lcss-file:
-lchunk-depth:
@@ -153,37 +153,32 @@ function DO_html {
if [ "$#" != "1" ]; then print_help_html 1>& 2; exit 1; fi;
doc_input="$1"
if [ ! -f "$doc_input" ]; then error "$doc_input: No such file"; fi
- doc_indir=$( (cd $(dirname $doc_input) && pwd) )
- doc_infile=$(basename $doc_input)
- if [ "x${doc_infile: -4}" == "x.xml" ]; then
- doc_inbase=${doc_infile:0:$((${#doc_infile}-4))}
- else
- doc_inbase="$doc_infile"
- fi
+ doc_indir=$( (cd $(dirname "$doc_input") && pwd) )
+ doc_infile=$(basename "$doc_input")
+ doc_inbase=$(basename "$doc_infile" ".xml")
+ if [ "$doc_inbase" = "$doc_infile" ]; then
+ doc_inbase=$(basename "$doc_infile" ".docbook")
+ fi;
- if [ "x$doc_output" == "x" ]; then
+ if [ "x$doc_output" = "x" ]; then
doc_outdir=`pwd`
- if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; fi
+ if [ "x$doc_extension" = "x" ]; then doc_extension='.xhtml'; fi
doc_outfile="${doc_inbase}${doc_extension}"
- elif [ -d "$doc_output" -o "${doc_output: -1}" == "/" ]; then
+ elif [ -d "$doc_output" -o $(echo "$doc_output" | sed -e 's/.*\/$/\//') = "/" ]; then
mkdir_p "$doc_output"
doc_outdir=`(cd "$doc_output" && pwd)`
- if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; fi
+ if [ "x$doc_extension" = "x" ]; then doc_extension='.xhtml'; fi
doc_outfile="${doc_inbase}${doc_extension}"
else
dir=`dirname "$doc_output"`
mkdir_p "$dir"
doc_outdir=`(cd "$dir" && pwd)`
doc_outfile=`basename "$doc_output"`
- if [ "x$doc_extension" == "x" ]; then
+ if [ "x$doc_extension" = "x" ]; then
doc_extension=`echo "$doc_outfile" | grep -o '\..*'`
fi;
fi;
- if [ "x${doc_outfile: -${#doc_extension}}" == "x${doc_extension}" ]; then
- doc_outbase="${doc_outfile:0:$((${#doc_outfile}-${#doc_extension}))}"
- else
- doc_outbase="${doc_outfile}"
- fi
+ doc_outbase=$(basename "$doc_outfile" "$doc_extension")
params='--param db.chunk.chunk_top 0'
params="$params --stringparam db.chunk.basename \"$doc_outbase\""
@@ -234,6 +229,10 @@ function DO_html {
command="$1";
+if [ "x$command" = "x" ]; then
+ print_help 1>&2;
+ exit 1;
+fi;
shift;
if [ "$command" = "html" ]; then
DO_html $@;