On Sun, Oct 03, 2010 at 01:56:36PM +0200, Marco Herrn wrote:
> I open a pdf file by calling:
>
> zxpdf my.pdf
>
> (The "zxpdf" is actually hidden in a bash alias with some other options I
> usually use.)
> Xpdf opens the my.pdf, but when I close xpdf, the file my.pdf has gone!
> This happens with all pdf file I have tried with.
>
> However it does not happen, if a call it via:
>
> /usr/bin/xpdf my.pdf
>
> so it seems to have something to do with zxpdf.
I was able to reproduce it. The cause is very simple. zxpdf is actually
a shell script and the error is very evident. I'm attaching a patch
which fixes the problem. This is the description of the solution which I
wrote on the patch:
theorem.
If a .pdf file name is passed as parameter and the file exists, then
$cat is empty and $tmp is set to the file name.
Around line 57, the script will remove the file which name is given by
$tmp whenever the signal trap is fired. Acording to our theorem,
removing file $tmp when $cat is empty is an error. After all, it will be
pointing to a file created by the user, not by us, so we should have no
business in removing it.
theorem.
If a .pdf file name is passed as parameter and the file exists, then
$cat is empty and $tmp is set to the file name.
Around line 57, the script will remove the file which name is given by
$tmp whenever the signal trap is fired. Acording to our theorem,
removing file $tmp when $cat is empty is an error. After all, it will be
pointing to a file created by the user, not by us, so we should have no
business in removing it.
---
debian/zxpdf | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
mode change 100644 => 100755 debian/zxpdf
diff --git a/debian/zxpdf b/debian/zxpdf
old mode 100644
new mode 100755
index c4ba2fb..1179359
--- a/debian/zxpdf
+++ b/debian/zxpdf
@@ -57,6 +57,8 @@ fi
if [ "$tmp" == "" ]; then
exec xpdf -title $title $flags
+elif [ -z "$cat" ]; then
+ xpdf -title $title $flags "$tmp" $pages
else
trap "rm -f \"$tmp\"" 0 1 2 15
xpdf -title $title $flags "$tmp" $pages
--
1.7.2.3