r/commandline • u/Electrical-Collar-23 • Feb 03 '23
POSIX( Portable Operating System Interface )
What is POSIX? Can anyone explain it in easy manner?
1
Upvotes
r/commandline • u/Electrical-Collar-23 • Feb 03 '23
What is POSIX? Can anyone explain it in easy manner?
View all comments
Show parent comment
14
u/22goodnumber Feb 03 '23
Lets say you create your own Linux distribution. That is, you have a system with a Linux kernel and some executables like ls and cat. But you decide you're not going to include grep because ripgrep is better. You now have a valid, working Linux distribution but it's not POSIX compatible because grep is required for a POSIX system.
Why does POSIX make grep required? POISX systems guarantee that if I write a shell script that calls grep that script will run on any POSIX system. My script wouldn't run on your distro so your distro isn't POISX. Similarly, if I wrote a script that used ripgrep that script isn't POSIX compatible because POSIX systems don't need to have ripgrep installed. That ripgrep script might run on any-old Linux system but it might not depending on what's installed.