Shell Scripting Pro Tip: Use Long-Form Arguments for Clarity
ChangelogMay 1, 20254 min195 views
3 connectionsΒ·5 entities in this videoβThe Value of Long-Form Arguments in Scripts
- π‘ Pro tip: When writing bash scripts, always use the long form of command arguments instead of short forms.
- π― While short forms like
-fare faster for one-liners, long forms like--file=make scripts self-documenting and easier to understand later. - π This is especially true for complex commands like
ffmpegwith numerous flags, where long forms clarify intent and avoid the need to consult man pages.
Historical Context and Reinforcement
- π§ The tip is an old but valuable one, potentially originating from a 2010 Changelog post by Adam Yang.
- π The advice is to force yourself to use the long form in scripts, even if short forms are used for command history or quick tasks.
- β This simple practice significantly improves script scrutability over inscrutability.
Examples of Ambiguity with Short Flags
- π Commands like
taroften use short flags such as-xvfor-xzf, where the exact meaning of each flag (x,v,z,f) can be forgotten. - β οΈ Without the long form, users might not recall if
-fmeans 'file' or 'format', or if-zis for 'zip' or another function. - π¬ Mnemonics or remembering the long form helps in recalling the specific function of each argument, like
cfor 'create' orxfor 'extract'.
Knowledge graph5 entities Β· 3 connections
How they connect
An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.
Hover Β· drag to explore
5 entities
Chapters2 moments
Key Moments
Transcript17 segments
Full Transcript
Topics9 themes
Whatβs Discussed
Shell ScriptingBash ScriptsCommand Line ArgumentsLong-Form FlagsSelf-Documenting CodeScripting Best Practicesffmpegtar commandChangelog
Smart Objects5 Β· 3 links
ConceptsΒ· 4
PersonΒ· 1