I have a project comprised of about 20 small
.sh files. I name these "small" because generally, no file has more than 20 lines of code. I took a modular approach because thus I'm loyal to the Unix philosophy and it's easier for me to maintain the project.
In the start of each
.sh file, I put
Simply put, I understand script declarations have two purposes:
- They help the user recall what shell is needed to execute the file (say, after some years without using the file).
- They ensure that the script runs only with a certain shell (Bash in that case) to prevent unexpected behavior in case another shell was used.
When a project starts to grow from say 5 files to 20 files or from 20 files to 50 files (not this case but just to demonstrate) we have 20 lines or 50 lines of script declarations. I admit, even though it might be funny to some, it feels a bit redundant for me to use 20 or 50 instead say just 1 per project (maybe in the main file of the project).
Is there a way to avoid this alleged redundancy of 20 or 50 or a much greater number of lines of script declarations by using some "global" script declaration, in some main file?