Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with pure SH #19

Open
chereskata opened this issue Dec 8, 2022 · 0 comments
Open

Compatibility with pure SH #19

chereskata opened this issue Dec 8, 2022 · 0 comments

Comments

@chereskata
Copy link

Hello,

i have made some adjustments to run this nice helper program in every SH compatible shell:

--- .local/bin/pdf2archive.orig
+++ .local/bin/pdf2archive
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 
 # PDF2ARCHIVE 0.3.2
 # (C) 2018 Matteo Seclì <[email protected]>

@@ -263,7 +241,7 @@
 [ -z ${PDFTRAPPED+x} ] && PDFTRAPPED=$(echo "$METADUMP" | grep "__knowninfoTrap
ped: " | sed "s/^__knowninfoTrapped: //g")
 # Replace "Trapped" string, if not empty, with an operator. Fixes 3Heights.
 if [ "$PDFTRAPPED" != "" ]; then
-  PDFTRAPPED="/$(tr '[:lower:]' '[:upper:]' <<< ${PDFTRAPPED:0:1})$(tr '[:upper:]' '[:lower:]' <<< ${PDFTRAPPED:1})"
+  PDFTRAPPED="/$(echo ${PDFTRAPPED:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${PDFTRAPPED:1} | tr '[:upper:]' '[:lower:]')"
 fi
 # Check if the operator is allowed, otherwise empty variable.
 if [ "$PDFTRAPPED" != "/True" ] && [ "$PDFTRAPPED" != "/False" ]; then

Additionally as i run an apparmor profile, it would be easier to allow one single /tmp/ghostscript directory for rw:

@@ -216,8 +190,12 @@
 if [ "$OUTPUT" == "" ]; then
     OUTPUT="${INPUT%.pdf}-PDFA.pdf"
 fi
-TMPDIR=$(mktemp -d)
-TMPDIR=$(mktemp -d)
+if [ ! -d /tmp/ghostscript ]; then
+    mkdir /tmp/ghostscript
+fi
+TMPDIR=/tmp/ghostscript
+TMPFILE=$TMPDIR/tmp.pdf
 PSTMPFILE=$TMPDIR/PDFA_def.ps
 ICCTMPFILE=$TMPDIR/AdobeRGB1998.icc

Use as you like and thank you for your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant