Skip to main content

Why I use long parameter names in scripts

The other day, I posted about a script I'd written that found the longest commit message in a repository.

As I couldn't find a native way to do this with Git, the script loops over each commit in the repository, calculates its length and stores the length and commit SHA in a file.

The lines in the file are sorted so the longest commit is first.

Whilst I commonly use short parameters, such as git add -p when typing commands, in scripts, I prefer to use the equivalent longer parameters, where possible.

For example, in the script, I execute this command to sort the lines:

sort "${result_file}" --reverse --numeric-sort --output "${result_file}"

This could be re-written as:

sort "${result_file}" -rn -o "${result_file}"

Whilst the original is more verbose and longer to type, I prefer its verbosity which makes it easier for me or others to read and understand in the future.

Was this interesting?

Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.

About me

Picture of Oliver

I'm a certified Drupal Triple Expert and former Drupal Association staff member with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.