Better Programming

Advice for programmers.

Follow publication

Member-only story

24 Bashism To Avoid for POSIX-Compliant Shell Scripts

Shinichi Okada
Better Programming
Published in
9 min readAug 19, 2021

--

Image by the author using Teffects blob.

Introduction

The Portable Operating System Interface for Unix (POSIX) is an international standard created by IEEE. By conforming to the POSIX standards, a wide variety of systems including Linux, macOS, and Windows can execute your scripts.

In this article, you will learn about POSIX, its commands, and tips on how to make your Shell scripts more POSIX compliant.

When variant UNIX versions are developed (System V and BSD variants) during the 1980s, shell script portability became difficult. The POSIX standardization was created in 1988. Each OS has a different default system shells as you see in the following table:

System Shell /bin/sh list.

Ubuntu’s default login shell remains bash, but a script using the #!/bin/sh shebang executes as POSIX dash. Dash is smaller in size and faster than Bash.

POSIX describes the contract between the application and the operating system. Following a standardization like POSIX allows your software to run on the largest possible set of UNIX-like environments.

--

--

Shinichi Okada
Shinichi Okada

Written by Shinichi Okada

A programmer and technology enthusiast with a passion for sharing my knowledge and experience. https://codewithshin.com

Responses (1)

Write a response