We need to normalize all of our bash scripts. This includes:
- Normalization and inclusion of correct shabangs in each script
- Ensuring all file extensions are the same (so in files with a
bash shabang, the file extension for these should be .bash). This can cause some messing with how the git history is tracked, so file extensions are not super high prority but we still need to hit this
- Correct usage of
return and exit within our bash commands.
- Utilization of shellformat and shell check. The specific usage is below:
shellcheck --enable=require-variable-braces,quote-safe-variables,add-default-case <fileToLintHere>
shfmt -i 4 -ci -fn <fileToFormatHere>
Bug Description:
A recent bug caused by this was the gems/tests/run_tests.sh script having a #!/bin/sh shabang which caused it to not have the bash source command available to it. Furthermore, inconsistencies increases brain usage which is bad and makes scripts that would grab all specific files etc. to run tools on them more difficult.
Additional context
Think of different shells as kinda like different programming langauges. They are not all interchangeable, so we gotta keep that in mind. If we just stick to bash shells that use the baseline commands/progs we should be good. Getting a collection of all our scripts without shabangs would be good for someones first issue, actually changing them and ensuring the shabangs are correct is dependent on the devs skill level
Information regarding shabangs:
Information Regarding exit vs. return
We need to normalize all of our bash scripts. This includes:
bashshabang, the file extension for these should be.bash). This can cause some messing with how the git history is tracked, so file extensions are not super high prority but we still need to hit thisreturnandexitwithin our bash commands.shellcheck --enable=require-variable-braces,quote-safe-variables,add-default-case <fileToLintHere>shfmt -i 4 -ci -fn <fileToFormatHere>Bug Description:
A recent bug caused by this was the
gems/tests/run_tests.shscript having a#!/bin/shshabang which caused it to not have the bashsourcecommand available to it. Furthermore, inconsistencies increases brain usage which is bad and makes scripts that would grab all specific files etc. to run tools on them more difficult.Additional context
Think of different shells as kinda like different programming langauges. They are not all interchangeable, so we gotta keep that in mind. If we just stick to
bashshells that use the baseline commands/progs we should be good. Getting a collection of all our scripts without shabangs would be good for someones first issue, actually changing them and ensuring the shabangs are correct is dependent on the devs skill levelInformation regarding shabangs:
Information Regarding
exitvs.returnreturnin our functions, and ngl we can useexitin our functions if the script is supposed to exit if a function fails but this pattern isnt very common. So let's just go forreturnon all our functions while usingexitto react to a failed functions return value