1

Currently I am doing essentially this:

if [[ "$OSTYPE" == "linux-gnu" ]]; then
  echo "a"
elif [[ "$OSTYPE" == "darwin"* ]]; then
  echo "b"
elif [[ "$OSTYPE" == "cygwin" ]]; then
  echo "c"
elif [[ "$OSTYPE" == "msys" ]]; then
  echo "d"
elif [[ "$OSTYPE" == "win32" ]]; then
  echo "e"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
  echo "f"
else
  echo "g"
fi

This would probably work fine for the major 3 systems (mac, windows, linux), but what about raspberry or raspberry bare metal, or other custom operating systems. Is there a way to instead check for the architecture, and is that typically done / is it sufficient? Can you actually write programs that target a specific architecture rather than an OS? I'm new to this, basically wondering if there's a way to write bash scripts and C such that it would work on bare metal machines or other obscure systems, that still use either x86 or arm.

1
  • 1
    Wouldn’t a Raspberry Pi just be running a Linux kernel? There are really only two CPU architectures x86 and ARM....
    – Ramhound
    Jul 8, 2019 at 0:47

0

You must log in to answer this question.

Browse other questions tagged .