PennLINC / babs

BIDS App Bootstrap (BABS)
https://pennlinc-babs.readthedocs.io
MIT License
5 stars 5 forks source link

All templated bash scripts should be "robust" and shellcheck-clean #166

Open yarikoptic opened 6 months ago

yarikoptic commented 6 months ago

Summary

ATM produced shell scripts do not adhere to the best practices of writing shell scripts . You can use https://www.shellcheck.net/ tool to see what is wrong with them, e.g.

here is an example of running on a sample produced script ```shell ❯ shellcheck /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh In /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh line 7: echo I\'m in $PWD using `which python` ^--^ SC2086 (info): Double quote to prevent globbing and word splitting. ^------------^ SC2046 (warning): Quote this to prevent word splitting. ^------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`. Did you mean: echo I\'m in "$PWD" using $(which python) In /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh line 8: path_check_setup=/home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup ^--------------^ SC2034 (warning): path_check_setup appears unused. Verify use (or export if used externally). In /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh line 18: which_python=`which python` ^------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`. Did you mean: which_python=$(which python) In /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh line 20: echo 'Calling `test_job.py`...' ^------------------------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that. In /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/call_test_job.sh line 21: ${which_python} /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/test_job.py --path-workspace ${current_pwd} --path-check-setup /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: ${which_python} /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup/test_job.py --path-workspace "${current_pwd}" --path-check-setup /home/yoh/proj/misc/babs/.testdata/babs_test_project/test_project/analysis/code/check_setup For more information: https://www.shellcheck.net/wiki/SC2034 -- path_check_setup appears unused. ... https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt... https://www.shellcheck.net/wiki/SC2016 -- Expressions don't expand in singl... ```