qpdf has some options which test various things about a pdf file and output a return code for easy scripting.
The manual for qpdf suggests that I can use code like this:
Code: Select all
if [ qpdf --is-encrypted *3* ]; then echo "yes"; else echo "no"; fi
It does not work (see second to last command below). Is the syntax in the manual wrong, or is there something weird about my bash or something in my environment?
Code: Select all
# qpdf --is-encrypted *2*
# echo $?
2
# qpdf --is-encrypted *3*
# echo $?
0
# qpdf --is-encrypted *2*
# if [ $? = 0 ]; then echo "yes"; else echo "no"; fi
no
# qpdf --is-encrypted *3*
# if [ $? = 0 ]; then echo "yes"; else echo "no"; fi
yes
# if [ qpdf --is-encrypted *3* ]; then echo "yes"; else echo "no"; fi
-bash: [: --is-encrypted: binary operator expected
no
# if [ $(qpdf --is-encrypted *3*) ]; then echo "yes"; else echo "no"; fi
no
Thanks.