I'm struggling to make find -exec accept my variable which contains a command with quotes...
signpath="codesign --force --deep --verbose --sign \"My Sign ID\""
Then no matter what version of find I try, I cannot succeed to exec the $signpath properly:
find "$pathtoframeworks" -type f -not -name '*.*' -exec "$signpath {}" \;
#the above results in codesign --force --deep --verbose --sign "My Sign ID" My App.app/Contents/Frameworks/MyFramework.framework/Versions/5/MyFramework: No such file or directory
find "$pathtoframeworks" -type f -not -name '*.*' -exec $signpath "{}" \;
#the above results in "My: no identity found
find "$pathtoframeworks" -type f -not -name '*.*' -exec "$signpath" {} \;
#the above results in codesign --force --deep --verbose --sign "My Sign ID": No such file or directory
find -exec seems to have trouble dealing with quotes within variables... What can I do ? :/
Try quoting it separately:
find "$pathtoframeworks" -type f -not -name '*.*' -exec "$signpath" '{}' \;
Though better and safer is to save command line in an array:
signpath=(codesign --force --deep --verbose --sign "My Sign ID")
And use it as:
find "$pathtoframeworks" -type f -not -name '*.*' -exec "${signpath[@]}" '{}' \;