From 4bd3723c02c1ea22d88a9c68a9d231abd5892f35 Mon Sep 17 00:00:00 2001 From: Mateusz Piotrowski <0mp@FreeBSD.org> Date: Wed, 5 Aug 2020 15:03:01 +0000 Subject: Make argument parsing a bit more robust Currently, when running mfh with a flag like --help the user gets a confusing error message from expr(1) like the following: > expr: illegal option -- - > expr: usage: expr [-e] expression > > revision "--help" should be a number This is not helpful. Instead, make sure that any arguments specified by the user are handled properly by expr(1). This results in a much cleaner error message: > revision "--help" should be a number Reviewed by: mat Approved by: portmgr (mat) Differential Revision: https://reviews.freebsd.org/D25958 --- Tools/scripts/mfh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Tools') diff --git a/Tools/scripts/mfh b/Tools/scripts/mfh index cf332ca43983..14e362687aac 100755 --- a/Tools/scripts/mfh +++ b/Tools/scripts/mfh @@ -85,7 +85,7 @@ else cdiffcmd=cat fi # I sure hope by 2030 we'll be doing something else. Yes, famous last words. -if expr "${branch}" : '20[12][0-9]Q[1-4]' > /dev/null; then +if expr -- "${branch}" : '20[12][0-9]Q[1-4]' > /dev/null; then shift if [ "${latest_branch}" != "${branch}" ]; then ask "/!\\ The latest branch is ${latest_branch}, do you really want to commit to ${branch}?" || exit 1 -- cgit v1.2.3