Skip to content

Compatibility with pure SH #19

@chereskata

Description

@chereskata

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions