--- scripts/pdfjoin.orig	2005-01-25 22:19:21.000000000 +0300
+++ scripts/pdfjoin	2008-12-29 20:00:05.000000000 +0300
@@ -23,12 +23,17 @@
 ##  
 ##  First say where your "pdflatex" program lives:
 ##
-pdflatex=pdflatex
+pdflatex="__LOCALBASE__"/bin/pdflatex
 #pdflatex="pdflatex.exe"    ## this for Windows computers
 ##
 ##  Next a permitted location for temporary files on your system:
 ##
-tempfileDir="/var/tmp" ## /var/tmp is standard on most unix systems
+## /var/tmp is standard on most unix systems
+tempfileDir=`mktemp -dq /var/tmp/pdfjoin.XXXXXXXX`
+if [ -z "$tempfileDir" ]; then
+	echo "pdfjoin: unable to create temporary directory"
+	exit 2
+fi
 #tempfileDir="C:/tmp"  ## use something like this under Windows
 ##
 ##  Now specify the default settings for pdfjoin:
@@ -50,12 +55,12 @@
 for d in /etc /usr/share/etc /usr/local/share /usr/local/etc
 do if test -f $d/pdfnup.conf; then
    echo "Reading site configuration from $d/pdfnup.conf"
-   source $d/pdfnup.conf
+   . $d/pdfnup.conf
    fi 
 done
 if test -f ~/.pdfnup.conf; then 
    echo "Reading user defaults from ~/.pdfnup.conf";
-   source ~/.pdfnup.conf; 
+   . ~/.pdfnup.conf; 
 fi
 #######################################################################
 ##
@@ -99,7 +104,7 @@
 ##
 ##  Check that necessary LaTeX packages are installed
 ##
-PATH=`dirname "$pdflatex"`:$PATH
+PATH="$PATH":"__LOCALBASE__"/bin
 export PATH
 case `kpsewhich pdfpages.sty` in
 	"") echo "pdfjoin: pdfpages.sty not installed"; exit 1;;
