1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tools/villas: improve script behaviour for -h or --help

- Quote `${SUBTOOL}` in case it is set but empty
- Add `-e` flag to `grep` so `villas --help` does not show `grep --help`
- Add `-F` flag to `grep` so `villas "[ "` does not show a regexp error
- Don't exit with error when `-h` or `--help` was specified
- Add `-h` and `--help` to `Usage` in the help message.

Signed-off-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de>
This commit is contained in:
Philipp Jungkamp 2023-05-26 01:03:14 +02:00
parent 7506e2c289
commit c194b621cb

View file

@ -22,8 +22,8 @@ SUBTOOL=$1
ARGS=${@:2}
# Check if tool is available
if ! echo ${SUBTOOLS} | grep -w -q ${SUBTOOL}; then
echo "Usage: villas [TOOL]"
if ! echo ${SUBTOOLS} | grep -wqFe "${SUBTOOL}"; then
echo "Usage: villas [-h | --help | TOOL]"
echo " TOOL is one of ${SUBTOOLS}"
echo
echo "For detailed documentation, please see: 'villas node'"
@ -32,7 +32,8 @@ if ! echo ${SUBTOOLS} | grep -w -q ${SUBTOOL}; then
# Show VILLASnode copyright and contact info
villas-node -h | tail -n3
exit 1
echo "-h" "--help" | grep -wqFe "${SUBTOOL}"
exit $?
fi
exec villas-${SUBTOOL} ${ARGS}