Skip to main content

${var?} and &&: Two simple tips for shell commands in tech docs

tl;dr: Use error-if-unset ${placeholders?} and join commands with && to make it easier and safer to copy-paste shell commands from technical documentation.

As typically placeholders in shell lines often are named PLACEHOLDER, $PLACEHOLDER or <PLACEHOLDER> this will eventually executed in some weird way. If used ${PLACEHOLDER?} this will break with an error, as $PLACEHOLDER is unset/undefined. „?“ is important here.

Bind two shell lines with && so that copy&paste and instantly execution break after first non executable command.

Look at Vidar's Blog.