Hi forum,
a bash script I wrote behaves unexpectedly (read: "There's a bug in it.") and I just don't get it.
Say there's that variable
PAGES
which contains
" page0.pdf page1.pdf page2.pdf"
. And there is
$1
which contains
"result.pdf"
.
I want to merge all those single-page pdf files into one multi-page pdf file. There's
pdfunite
for that. The first line of the code snippet prints to the screen what the script is trying to execute, the second line does just that (or so I thought).
echo pdfunite "$PAGES" "$1"
pdfunite "$PAGES" "$1"
At that point,
pdfunite
prints its help message. Therefore I guess that something is wrong with the arguments I gave it.
But when I copy the output of the first line to the command prompt of the very terminal the script ran in, it
pdfunite
s everything together perfectly.
So: Where's the difference in executing something (which does not work) to printing it to the console and copying it onto a new line to execute (which does work)?
What I have tried:
Printed the command in question to the console before actually executing it. And tried to execute the printed-out version (which actually works).