summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-20 03:05:53 +0000
committerBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-20 03:05:53 +0000
commit69aeb5e269ee0d7c9dffb11489899b7011d46e1c (patch)
tree2584ae0bf1ff00765c5b4d3b93eda55c64e81f76
parentc3b5542f7248dcf73677d52a69a3989c519c8022 (diff)
downloadwgetpaste-69aeb5e269ee0d7c9dffb11489899b7011d46e1c.tar.gz
Fix -- handling. Die on unrecognized options.
-rwxr-xr-xwgetpaste10
1 files changed, 7 insertions, 3 deletions
diff --git a/wgetpaste b/wgetpaste
index b6a8a5b..cd8c5bd 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -8,13 +8,14 @@ VERSION="2.1"
### helper functions
+# print multiple lines
print() {
for arg in "${@}"; do
echo -e "${arg}"
done
}
-# show an error message and die
+# show error message(s) and die
die() {
print "${@}" 1>&2
exit 1
@@ -374,6 +375,9 @@ get_filename() {
while [[ -n "${1}" ]]; do
case "${1}" in
+ -- )
+ shift && get_filename "${@}" && break
+ ;;
-c | --command )
[[ -z "${2}" ]] && no_argument "${1}"
SOURCE="command"
@@ -450,8 +454,8 @@ while [[ -n "${1}" ]]; do
SOURCE="xcut"
shift
;;
- -- )
- shift && get_filename "${@}" && break
+ -* )
+ die "${0}: unrecognized option \`${1}'"
;;
*)
get_filename "${1}" && shift