POSIX原理主義

From Esolang
Jump to navigation Jump to search

POSIX原理主義 (POSIX fundamentalism), also known as POSIXism, or in more wide context POSIX中心主義 (POSIX Centralism) is a software development method originally proposed by 松浦リッチ研究所.

Its intension is to make a sustainable and portable software using just POSIX-compatible shellscript with utilities standardized in POSIX. (Later, he had went to POSIX-C development to achieve that)

It is essentially a kind of Wikipedia:Shellscript subset. Because of coding style, it can be considered as a part of esoteric subset.

History

Shell Script ライトクックブック in 2004. Was just a cookbook because everyone else had preferred Perl, Ruby and Python but not shellscript at all.

The first mention of the word "POSIX原理主義" in Shell Script ライトクックブック 2014. More POSIX-centric contents than previous one. Some contents are available on Qiita.

Went to academic way.

Shell Script ライトクックブック 2014-2015(第3版); more serious methods to develop an application including

  • date arithmetics
  • CSV/JSON/XML parser
  • PIPESTATUS (from Bash) equivalent
  • file lock and semaphore
  • Table JOIN
  • sending mail (as well as attaching a file)
  • HTTP POST
  • ajax
  • Cookie
  • management of HTTP session
  • how to debug without IDE

Coding style

One program per one file. Prefer piping over separating into functions. Reinvent the wheel as well as possible.

Boilerplate

#!/bin/sh

#################################################################################
#
# Utility Name - Description
#
# What is this?
# Massive description below.
#
# Written by Author Name on Last Edit Time
#
# Massive Copyright notation.
#
#################################################################################

# == Initialized ==
set -eu
umask 0022
export LC_ALL=C
if _p="$(command -p getconf PATH 2>/dev/null)"; then
  export PATH="$_p${PATH+:}${PATH:-}"
fi
export UNIX_STD=2003 POSIXLY_CORRECT=1

Reimplementing utilities outside of POSIX standard

He proposed that utilities such as base64 and mktemp should be reimplemented in POSIXism manner.

Permitting utilities outside of POSIX standard

He pointed out that the POSIX standard lacks internet communication and fast binary utilities; he proposed it is permitted to use utilities outside of the standard if and only if they can be substituted by other one.

This technique can be seen on his Twitter client for command line Kotoriotoko: it depends on

  • OpenSSL or LibreSSL to use the OpenSSL(1) command for OAuth 1.0; and
  • wget(1) or curl(1) to access Twitter web API.

Web programming

Shellscript CGI scripts of web application, as well as JavaScript within range of W3C (back then) standards; no JavaScript library shall be permitted unless you reimplement it.

One example of the project is MQTTwrapper.

See also

External Resources