Larger Script Organization
Script Layout
Pick a Shape
As scripts grow, project layout matters. A single-file script can stay small, while a project layout separates entry points, helpers, and tests.
Program
Play the script to choose the layout and see the planned entry point and directories.
script_layout_plan.sh
#!/usr/bin/env bash
layout=
if [ "$layout" = "project" ]; then
entry="bin/deploy"
dirs="bin lib test"
else
entry="./deploy.sh"
dirs="."
fi
echo "$layout:$entry:$dirs"
#!/usr/bin/env bash
layout=
if [ "$layout" = "project" ]; then
entry="bin/deploy"
dirs="bin lib test"
else
entry="./deploy.sh"
dirs="."
fi
echo "$layout:$entry:$dirs"
layout
Layout is the file and directory shape of the script project.
entry point
The entry point is the executable script users run.
test directory
A larger layout makes room for tests beside helpers and entry points.