Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  85] [ 0]  / answers: 1 / hits: 38094  / 2 Years ago, sun, march 13, 2022, 9:24:20

I have some functional scripts and I want to copy to /usr/bin I want to use them as normal terminal commands. Is it a good practice to use them with the .sh extension or can I save them without extension?


More From » scripts

 Answers
1

No, it is not a good practice, you should keep your scripts without extension. Note, that scripts being part of packages doesn't have a .sh extension, i.e. update-grub, not update-grub.sh. If you are still not convinced, then be advised, that Google Shell Style Guide says:




Executables should have no extension (strongly preferred) or a .sh extension. Libraries must have a .sh extension and should not be executable.




PS You don't have to put your script into /bin. You can create directory ~/bin and put your script there. Directory ~/bin is included in $PATH by default, so scripts put there can be run as any other shell command.


[#23959] Monday, March 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ouschee

Total Points: 485
Total Questions: 88
Total Answers: 106

Location: Central African Republic
Member since Mon, Aug 10, 2020
4 Years ago
ouschee questions
;