Re:Shell Script Best Practices, from a decade of scripting t...
by asicsp on Thursday October 27, 2022 @04:54AM
(#33354966)
My thumb rule is no extension if the script goes to the local bin folder and `.sh` otherwise. Beyond syntax highlighting, the extension also helps for wildcard matching for file operations (`ls`, `cp`, `for` loop, etc).
[ Parent
| on HN ]
Re:Shell Script Best Practices, from a decade of scripting t...
by _wolfie_ on Thursday October 27, 2022 @05:43AM
(#33355320)
Though in any non-trash editor you get syntax highlight based on shebang line alone.
One advantage of no-extension is that you can swap the implementation language later without "breaking" shell history for people in your team.
Re:Shell Script Best Practices, from a decade of scripting t...
by Sponge5 on Thursday October 27, 2022 @05:45AM
(#33355330)
What I do is have a scripts folder where the names have extensions and which is version controlled and symlink them from `.local/bin`
Re:Shell Script Best Practices, from a decade of scripting t...
by nrvn on Thursday October 27, 2022 @05:49AM
(#33355366)
And this rule has been followed the majority(if not all) interpreted and scripting languages. The likes of Ruby, python and JS have multiple examples. Whatever executable is in your $PATH it won’t have an extension.
Not sure if this convention is actually documented anywhere.
Random examples:
- https://github.com/PyCQA/isort/blob/main/pyproject.toml#L100
- https://github.com/pypa/pip/blob/main/setup.py#L78
- https://github.com/11ty/eleventy/blob/master/package.json#L1...
Re:Shell Script Best Practices, from a decade of scripting t...
by 0xbadcafebee on Thursday October 27, 2022 @11:24AM
(#33358967)
shellcheck *.sh FTW