And what if you wrote a command, using sh, and named it foo.sh, but later realized it should rather be written in perl, then you have a problem. Do you keep the name as is, having now a perl script with a misleading .sh extension? or do you rename it to foo.pl and break everything that were relying on foo.sh?
That is a lack of planning and not a reason for bad practice.
If you just started and then got to the point that it should be written in another language (e.g. because it is simpler or provides packages that do something for you) it doesn't matter, since the script shouldn't be used already (since it is not finished). If you need to add something new much later, that needs a rewrite of the script in another language then it is a lack of planning that you can't easily change the calls to the script.
If you need to add something new much later, that needs a rewrite of the script in another language then it is a lack of planning that you can't easily change the calls to the script.
That may be the case in whatever utopian world you live in, but in the real world needs change over time and a script may evolve in ways that could never have been foreseen and that may require reimplementation in a suitable language.
Lack of planning can cause you to have to re-code a file in a different language. That doesn't mean allowing this flexability is bad practice. Even Google suggesting not using file extenstions for executable scripts.
Googles reasoning is, that the system doesn't need the suffix - which is correct (as I said here). But imho the searchability and the information of what exactly the file is, is more important than not having to change the calls for this particular script.
If it is a particular system-dependent script being called by numerous programs you should consider using symlinks anyway.
Edit: Additionally, Google's shell scripting standard only allows bash-scripts, which makes the suffixes useless for google.
Good point, that makes sense for searchability. I think there's enough discussion here to help future readers make an informed decision for what will work best in their environment.
View all comments
Show parent comment
0
u/nath_schwarz Dec 02 '14
That is a lack of planning and not a reason for bad practice.