EtiennePerot / parcimonie.sh

Refresh your GnuPG keyring without disclosing your whole contact list to the world
Do What The F*ck You Want To Public License
225 stars 15 forks source link

Fixes for Mac OSX #1

Closed joelpurra closed 10 years ago

joelpurra commented 10 years ago

Running parcimonie.sh on Mac OSX 10.9 Mavericks (perhaps with custom versions of some tools) failed for me.

Here are the steps taken to fix them:

$ ./parcimonie.sh
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
No GnuPG keys found.

Editing parcimonie.sh to use sed -E instead, removing /i ignore case flag etcetera.

$ ./parcimonie.sh
expr: not a decimal number: '                636261616                                                '
expr: not a decimal number: '      89'
> Sleeping  seconds before refreshing key 4C47B4FF173AE6ED0DB733946DF6890D2A977668...

Testing the commands called from parcimonie.sh.

# Commands in getPublicKeys() called from getNumKeys()
# Note the whitespace surrounding the number
$ gpg --list-public-keys --fixed-list-mode --fingerprint --with-key-data | grep -E '^fpr:' | wc -l
      89
$ # Commands in getRandom()
$ # Note the whitespace and the trailing newline/empty line
$ od -vAn -N4 -tu4 < /dev/urandom
               1315831259

$ od -vAn -N4 -tu4 < /dev/random
                 46678454

Now editing parcimonie.sh to remove whitespace around numbers, including newlines/empty lines, keeping only the digits.

$ ./parcimonie.sh
> Sleeping 2922 seconds before refreshing key 4C47B4FF173AE6ED0DB733946DF6890D2A977668...

The changes are present in the mac-osx-fixes-sed-expr branch in my fork. Because this is a quick, non-portable hack, I'm not going to submit a pull request. Hope someone else might find it useful though!

EtiennePerot commented 10 years ago

This is cool. Do you plan on making it portable so that it can be merged in? The thing to remove whitespace should be safe already. The other one can be done by wrapping sed in its own function that tries to run it with one argument, and runs it with the other if it fails.

joelpurra commented 10 years ago

@EtiennePerot: not what I planned to do, but since you seem to approve of the general approach, I did.

Now, if I could only get torsocks to work properly so I can actually use this script ;)

EtiennePerot commented 10 years ago

not what I planned to do, but since you seem to approve of the general approach, I did.

Do you mean you didn't plan to submit changes, or that you planned to make them some other way?

Closing this as #2 should be the main thread for this now.

joelpurra commented 10 years ago

@EtiennePerot: was pressed for time late Friday afternoon, and hadn't thought of an easy enough fix for the portable sed check to submit a complete patch. Your quick reply made me look into it though!