1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-20 00:21:35 +00:00

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
This commit is contained in:
Mateusz Piotrowski 2020-08-05 15:03:01 +00:00
parent 1c843dbb6a
commit 4bd3723c02
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=544225

View File

@ -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