Skip to content

Instantly share code, notes, and snippets.

@bef
Created June 15, 2023 08:17
Show Gist options
  • Save bef/f631f31355e7e1a44819cf4691da3e8f to your computer and use it in GitHub Desktop.
Save bef/f631f31355e7e1a44819cf4691da3e8f to your computer and use it in GitHub Desktop.
Check architecture of MacOS binary or Application bundle
#!/bin/bash
## Check architecture of MacOS binary or Application bundle
## // Ben Fuhrmannek 2023-06-15
for i in "$@"; do
if [[ ! -e "$i" ]]; then
echo "ERROR: $i: not found"
continue
fi
if [[ -d "$i" && -f "$i/Contents/Info.plist" ]]; then
i="$i/Contents/MacOS/$(defaults read "$(realpath "$i")/Contents/Info.plist" CFBundleExecutable)"
fi
if [[ -x "$i" ]]; then
echo "## checking $i"
i_file=$(file "$i")
# echo "$i_file"
if echo "$i_file" |grep -q "executable arm64"; then
echo " > ARM64"
elif echo "$i_file" |grep -q "executable x86"; then
echo " > Intel"
else
echo "$i_file"
fi
continue
fi
echo "ERROR: $i: incompatible file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment