Skip to main content

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 -f are 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 ffmpeg with 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 tar often use short flags such as -xvf or -xzf, where the exact meaning of each flag (x, v, z, f) can be forgotten.
  • ⚠️ Without the long form, users might not recall if -f means 'file' or 'format', or if -z is for 'zip' or another function.
  • πŸ’¬ Mnemonics or remembering the long form helps in recalling the specific function of each argument, like c for 'create' or x for '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