Hi,
Just sharing a tip for when you write sh or bash scripts. Use a static
analysis tool like 'shellcheck' on the scripts.
https://www.shellcheck.net/
Readme at GitHub has more examples and details:
https://github.com/koalaman/shellcheck
I would recommend that you run it on scripts you write.
Note: If our scripts didn't trigger issues (see below), we could create a
CI job to repeatedly run shellcheck and catch future issues directly.
/Christian
Below is an example of running it on one of our scripts.
$ shellcheck development/tools/count_lines_of_included_code.sh
*In development/tools/count_lines_of_included_code.sh line 5:*
l=`g++ $inc -DQT_NO_KEYWORDS -DQT_NO_STL -E 1.cpp | wc -l`
^-- SC2006: Use $(..) instead of legacy `..`.
^-- SC2086: Double quote to prevent globbing and word
splitting.
*In development/tools/count_lines_of_included_code.sh line 6:*
printf "%-40s: %d\n" $i $l
^-- SC2086: Double quote to prevent globbing
and word splitting.
^-- SC2086: Double quote to prevent
globbing and word splitting.
As you can see from above, the first issue is just a warning and not much
of a problem.
The second issue might be a problem depending on the actual file names. In
this case, I doubt we have source files with spaces or similar in their
names.
Below is a list of LyX scripts for which the shellcheck indicates at least
something:
HEAD @ chrid-mb $ find . -name "*.sh" -exec bash -c 'shellcheck "$1" >
/dev/null || echo "Issue found with: $1"; ' "" {} \;
Issue found with: ./3rdparty/boost/extract.sh
Issue found with: ./autogen.sh
Issue found with: ./development/attic/rename.sh
Issue found with: ./development/autotests/export-in.sh
Issue found with: ./development/autotests/run-tests.sh
Issue found with: ./development/autotests/single-test.sh
Issue found with: ./development/keystest/add_write_perms.sh
Issue found with: ./development/keystest/cache-bisect.sh
Issue found with: ./development/keystest/doNtimes.sh
Issue found with: ./development/keystest/killtest.sh
Issue found with: ./development/keystest/killtestpy.sh
Issue found with: ./development/keystest/list_all_children.sh
Issue found with: ./development/keystest/lyx_make.sh
Issue found with: ./development/keystest/main.sh
Issue found with: ./development/keystest/make_screen_shots.sh
Issue found with: ./development/keystest/maketar.sh
Issue found with: ./development/keystest/report.sh
Issue found with: ./development/keystest/report_html.sh
Issue found with: ./development/keystest/reproduce.sh
Issue found with: ./development/keystest/setup.sh
Issue found with: ./development/keystest/shared_functions.sh
Issue found with: ./development/keystest/shared_variables.sh
Issue found with: ./development/keystest/watch_keytest.sh
Issue found with: ./development/LyX-Mac-binary-release.sh
Issue found with: ./development/MacOSX/set_bundle_display_options.sh
Issue found with: ./development/tools/count_lines_of_included_code.sh
Issue found with: ./development/tools/count_total_lines_of_compiled_code.sh
Issue found with: ./development/tools/header_check.sh
Issue found with: ./development/tools/list_included_headers.sh
Issue found with: ./development/tools/separator-convert.sh
Issue found with: ./development/tools/update-po.sh
Issue found with: ./development/tools/updatelfuns.sh
Issue found with: ./development/tools/updatestats.sh