]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tmplcvt: make the tool more robust
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 5 Apr 2017 13:22:55 +0000 (10:22 -0300)
committerJonathan Corbet <corbet@lwn.net>
Tue, 11 Apr 2017 20:35:15 +0000 (14:35 -0600)
Currently, the script just assumes to be called at
Documentation/sphinx/. Change it to work on any directory,
and make it abort if something gets wrong.

Also, be sure that both parameters are specified.

That should avoid troubles like this:

$ Documentation/sphinx/tmplcvt Documentation/DocBook/writing_usb_driver.tmpl
sed: couldn't open file convert_template.sed: No such file or directory

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/sphinx/tmplcvt

index 909a73065e0a5b9c0b4d680b94d2e738698f606c..6848f0a26fa54362d05fe0b4344686b78523c853 100755 (executable)
@@ -7,13 +7,22 @@
 # fix \_
 # title line?
 #
+set -eu
+
+if [ "$#" != "2" ]; then
+       echo "$0 <docbook file> <rst file>"
+       exit
+fi
+
+DIR=$(dirname $0)
 
 in=$1
 rst=$2
 tmp=$rst.tmp
 
 cp $in $tmp
-sed --in-place -f convert_template.sed $tmp
+sed --in-place -f $DIR/convert_template.sed $tmp
 pandoc -s -S -f docbook -t rst -o $rst $tmp
-sed --in-place -f post_convert.sed $rst
+sed --in-place -f $DIR/post_convert.sed $rst
 rm $tmp
+echo "book writen to $rst"