summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-04-22 22:36:35 +0200
committerDave Reisner <dreisner@archlinux.org>2012-04-22 22:52:27 +0200
commit33cb63365749e76f6996f2c1a45a5f38dee00450 (patch)
treeea8226d8983c2d52e8466e16173e0ffc51d6f389
parent6d5115c0c1c1e9293d589e25cdde82f0157a81f0 (diff)
downloadmkinitcpio-33cb63365749e76f6996f2c1a45a5f38dee00450.tar.gz
mkinitcpio-33cb63365749e76f6996f2c1a45a5f38dee00450.tar.xz
functions: align error output with GNU getopt_long
Display the name of the program. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions15
1 files changed, 7 insertions, 8 deletions
diff --git a/functions b/functions
index e116005..127a830 100644
--- a/functions
+++ b/functions
@@ -35,7 +35,7 @@ parseopts() {
return 255 ;;
*)
# fail, ambiguous match
- error "option '%s' is ambiguous; possibilities:%s" \
+ printf "%s: option '%s' is ambiguous; possibilities:%s\n" "${0##*/}" \
"--$1" "$(printf " '%s'" "${longmatch[@]%:}")"
return 254 ;;
esac
@@ -53,7 +53,7 @@ parseopts() {
# option doesn't exist
if [[ $shortopts != *$opt* ]]; then
- error "invalid option '%s'" "$opt"
+ printf "%s: invalid option -- '%s'\n" "${0##*/}" "$opt"
OPTRET=(--)
return 1
fi
@@ -72,7 +72,7 @@ parseopts() {
break
# parse failure
else
- error "option '%s' requires an argument" "-$opt"
+ printf "%s: option '%s' requires an argument\n" "${0##*/}" "-$opt"
OPTRET=(--)
return 1
fi
@@ -85,7 +85,7 @@ parseopts() {
case $? in
0)
if [[ $optarg ]]; then
- error "option '%s' does not allow an argument" "--$opt"
+ printf "%s: option '--%s' doesn't allow an argument\n" "${0##*/}" "$opt"
OPTRET=(--)
return 1
else
@@ -104,7 +104,7 @@ parseopts() {
OPTRET+=("--$opt" "$2" )
shift 2
else
- error "option '%s' requires an argument" "--$opt"
+ printf "%s: option '--%s' requires an argument\n" "${0##*/}" "$opt"
OPTRET=(--)
return 1
fi
@@ -116,12 +116,11 @@ parseopts() {
return 1
;;
255)
- error "invalid option '%s'" "--$opt"
+ # parse failure
+ printf "%s: unrecognized option '%s'\n" "${0##*/}" "--$opt"
OPTRET=(--)
return 1
;;
- *)
- error "internal error: invalid option in longopt array '%s'" "--$opt"
esac
;;
*) # non-option arg encountered, add it as a parameter