1.3 KiB
title | date | permalink | tags | cta | snippet | ||||
---|---|---|---|---|---|---|---|---|---|
Why I use long parameter names in scripts | 2024-05-23 | daily/2024/05/23/why-i-use-long-parameter-names-in-scripts |
|
~ | Why I use long parameter names in scripts, such as `--force` instead of `-f`. |
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.