Similar to "How to find Bundle Identifier from known PID?" and to "How to read plist information (bundle id) from a shell script, but different.. as those are both related to Xcode build variable expansion, etc.
My question is how, in a BASH shell, where they only known value is the process' PID, how can one obtain that process' PATH, or unique "Bundle ID".
I am sure there is a hideous regex to parse ps, but I'm hoping for something cleaner and more portable. The comments in those prior mentioned posts included
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}")
However, I do not think plistbuddy
is installed on every Mac, and more importantly, my question is within a theoretical script, NOT within an Xcode build phase..
I've tried plutil
, plistkit
, and plistdump
, and none of them seem to do the trick..
The reason I am trying to achieve this is to be able to execute defaults read
/ write
functions without hardcoding the BundleID of the parent process. I know how to pass this info as an argument to a script.. but I want to be able to doubt check.. within the script.