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

Doesn't work on OSX, need to change sed flag #1

Closed
joschu opened this issue Dec 4, 2016 · 7 comments
Closed

Doesn't work on OSX, need to change sed flag #1

joschu opened this issue Dec 4, 2016 · 7 comments

Comments

@joschu
Copy link

joschu commented Dec 4, 2016

I got a bunch of errors on OSX saying "invalid command code..."
Fixed by switching -i to -i '' based on this stackoverflow post: http://stackoverflow.com/questions/7573368/in-place-edits-with-sed-on-os-x
Thanks for posting this great tool!

diff --git a/pdf2pptx.sh b/pdf2pptx.sh
index 75202f9..d65570e 100755
--- a/pdf2pptx.sh
+++ b/pdf2pptx.sh
@@ -52,19 +52,19 @@ function add_slide {
        id=$((id+8))
        entry='<Relationship Id=\"rId'$id'\" Type=\"http:\/\/schemas\.openxmlformats\.org\/officeDocu
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../_rels/presentation.xml.rels
+       sed -i '' "s/${pat}/${rep}/g" ../_rels/presentation.xml.rels

        pat='slide1\.xml\" ContentType=\"application\/vnd\.openxmlformats-officedocument\.presentatio
        entry='<Override PartName=\"\/ppt\/slides\/slide-'$1'\.xml\" ContentType=\"application\/vnd\.
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../../\[Content_Types\].xml
+       sed -i '' "s/${pat}/${rep}/g" ../../\[Content_Types\].xml

        sid=$1
        sid=$((sid+256))
        pat='<p:sldIdLst>'
        entry='<p:sldId id=\"'$sid'\" r:id=\"rId'$id'\"\/>'
        rep="${pat}${entry}"
-       sed -i "s/${pat}/${rep}/g" ../presentation.xml
+       sed -i '' "s/${pat}/${rep}/g" ../presentation.xml
 }

 function make_slide {
@@ -84,7 +84,7 @@ done
 if [ "$makeWide" = true ]; then
        pat='<p:sldSz cx=\"9144000\" cy=\"6858000\" type=\"screen4x3\"\/>'
        wscreen='<p:sldSz cy=\"6858000\" cx=\"12192000\"\/>'
-       sed -i "s/${pat}/${wscreen}/g" ../presentation.xml
+       sed -i '' "s/${pat}/${wscreen}/g" ../presentation.xml
 fi
 popd
@ashafaei
Copy link
Owner

Hello @joschu

Thanks for taking the time to resolve this issue and thanks for reporting it to me. I'll apply your fix.

Cheers.
PS> I enjoyed your tutorial last week.

@joschu
Copy link
Author

joschu commented Dec 15, 2016

Hah, funny coincidence that you were at my talk -- glad you liked it!

@myildi
Copy link

myildi commented Feb 15, 2018

Thank you very much to both, for the very useful script and for the correction for OSX!

@smeagolthellama
Copy link

shouldn't this be a) closed or b) a pull request?

@tddschn
Copy link

tddschn commented Jun 6, 2019

I am on OSX (10.14.5).

After patching the original script using

patch < (your_diff_file_above)

I got a new file './pdf2pptx.sh.rej'

then I try to convert my pdf file '5FA.pdf' to a pptx file, I got this error message:

$ ./pdf2pptx.sh.rej 5FA.pdf
./pdf2pptx.sh.rej: line 1: 5FA.pdf: command not found
./pdf2pptx.sh.rej: line 2: 5FA.pdf: command not found
./pdf2pptx.sh.rej: line 15: p:sldIdLst: No such file or directory
./pdf2pptx.sh.rej: line 26: +: command not found
./pdf2pptx.sh.rej: line 29: Override: No such file or directory
./pdf2pptx.sh.rej: line 31: +: command not found
./pdf2pptx.sh.rej: line 34: 5FA: value too great for base (error token is "5FA")

I don't know how to solve this problem. can you help me? thanks in advance!

@ashafaei
Copy link
Owner

Hi @tddschn ,
I'm not sure what's going on. I think the new file you're trying to run may be corrupted during the process. The suggested change above is easy to apply, I'd recommend you do it manually.

There are four instances of sed -i that you should change to sed -i ''. Apprently OSX expects an empty string '' after the -i command. That's it.

@kpj kpj mentioned this issue Jun 24, 2019
@ashafaei
Copy link
Owner

The latest commit fixes this issue through a pull-request. I'm closing the issue.

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

5 participants