matteosecli / matteosecli/pdf2archive
Compatibility with pure SH
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 87
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
i have made some adjustments to run this nice helper program in every SH compatible shell:
```diff
--- .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ì
@@ -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:
```diff
@@ -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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .local/bin/pdf2archive, especially its Bash shebang, PDFTRAPPED handling, and temporary-file setup around OUTPUT. Test the script with a pure sh-compatible shell and verify the proposed /tmp/ghostscript paths work with the AppArmor constraint. Done means the helper runs under sh and produces the expected PDF/A output without Bash-only syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100