The Saga of Code is a series of experiments for programmers to learn a language by:
-
reading an authoritative specification and writing short examples of code to illustrate the specification
-
running the examples using an open source implementation and reading the source code to understand observed behaviors
In the first episode of the series, I learn Unix Shell programming from POSIX Shell and Utilities specification and the source code of DASH.
You can find the example shell scripts grouped by topic in the folder
examples. You can run each example with dash or the standard interpreter
sh already installed on your system.
The dash executable can be run from dash/src/dash in this project,
it is already present in the git repository. If you wish to recompile it,
delete the file and follow the procedure below.
# from the root of this project
cd dash
./autogen.sh
./configure
make
If you wish to delete the temporary files generated by the build
(and not already part of the git repository), you can run git clean
to remove all untracked files and repositories:
# make sure that you run this command in the expected repository
pwd
# dry-run: check which files and directories will be deleted
git clean -f -d -n
# delete untracked files and repositories
git clean -f -d
The POSIX specification is intended for implementers rather than users of the Shell programming language. It describes border cases, parsing tokens and undefined effects left to the freedom of the implementer in minute details without providing an overview of the language.
I recommend the following reading order to start with the most general aspects of the language and uncover finer details step by step:
Eric Bréchemier
github@eric.brechemier.name