Is there a (relatively) simple way to test if an executable not only exists, but is valid?By valid, I mean that an x86_64 Mach-O (OS X) executable will not run on an ARM Raspberry Pi. However, simply running tool-osx || tool-rpi works on OS X, where the executable runs, but does not fall back to tool-rpi when the x86_64 fails.How can I fall back to another executable when one is invalid for the processor architecture?
Test if valid executable
shell;cpu;cpu architecture
Rather than testing for a valid executable, it's probably best to test what the current architecture is, then select the proper executable based on that.  For example:if [ $(uname -m) == 'armv6l' ]; then    tool-rpielse    tool-osxfiHowever, if testing the executable is what you really want to do, GNU file can tell you the architecture of an executable:user@host:~$ file $(whereis cat)ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x4e89fd8f129f0a508afa325b0f0f703fde610971, stripped