Invalid sed option on Yosemite
omegadan opened this issue · 3 comments
omegadan commented
➜ cert-chain-resolver-master ./resolve.sh ssl.crt ssl1.crt
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
Error (empty subject).
I don't think OS X sed supports -r
tbaschak commented
👍
On OSX using macports, installing/using gsed fixes this for me.
Patch for this:
diff --git a/resolve.sh b/resolve.sh
index 51417d6..4f6a28f 100755
--- a/resolve.sh
+++ b/resolve.sh
@@ -25,7 +25,7 @@ openssl x509 -in $FILENAME -out $CURRENT_FILENAME
I=1
while true; do
# get certificate subject
- CURRENT_SUBJECT=$(openssl x509 -in $CURRENT_FILENAME -noout -text | grep 'Subject: ' | sed -r 's/^[^:]*: //')
+ CURRENT_SUBJECT=$(openssl x509 -in $CURRENT_FILENAME -noout -text | grep 'Subject: ' | gsed -r 's/^[^:]*: //')
if [ -z "$CURRENT_SUBJECT" ]; then
echo "Error (empty subject)."
@@ -37,7 +37,7 @@ while true; do
cat $CURRENT_FILENAME >> $OUTPUT_FILENAME
# get issuer's certificate URL
- PARENT_URL=$(openssl x509 -in $CURRENT_FILENAME -noout -text | grep 'CA Issuers' | sed -r 's/^[^:]*://')
+ PARENT_URL=$(openssl x509 -in $CURRENT_FILENAME -noout -text | grep 'CA Issuers' | gsed -r 's/^[^:]*://')
if [ -z $PARENT_URL ]; then
echo
zakjan commented
Thanks for your contribution!
Unfortunately I didn't noticed the code before, I have already replaced sed
with awk
. I hope you have it on OSX ;) See latest master 9bceea2
zakjan commented
It works, see this comment. Closing. 9bceea2#commitcomment-9333422