From 8c67cad1f2bbcaabe23586643d670ba08f3d2a05 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jun 2016 22:30:19 -0400 Subject: Clean up. Mostly have error handling be a mode. You probably want to ignore whitespace change when viewing this diff. --- common.sh.in | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'common.sh.in') diff --git a/common.sh.in b/common.sh.in index 614f462..b2b4768 100644 --- a/common.sh.in +++ b/common.sh.in @@ -1,6 +1,6 @@ # begin common.sh {{{ -# Copyright (C) 2013-2014 Luke Shumaker +# Copyright (C) 2013-2014, 2016 Luke Shumaker # # This file is not considered part of GNU Emacs. # @@ -17,6 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +unset IFS +IFS=$' \t\n' + if type gettext &>/dev/null; then _() { gettext "$@"; } else @@ -48,10 +51,6 @@ emacs_quote() { printf -- '"%s" ' "${args[@]}" # wrap them in quotes, return } -bash_quote() { - printf -- '%q ' "$@" -} - version() { print '%s (Emacs utils) %s, %s' \ "${0##*/}" @VERSION@ "$(emacsclient --version)" @@ -106,4 +105,17 @@ emacs_usage() { emacsclient --help | grep -E '^(\s|-)' } + +next() { + local mode=$1 + shift + case "$mode" in + error) print "Try \``%q --help'' for more information" "$0" >&2; return 1;; + usage) usage; return 0;; + version) version; return 0;; + normal) exec -- "$@";; + *) error 'Internal error. The programmer writing this tool screwed up.'; exit 1;; + esac +} + # }}} end common.sh -- cgit v1.2.3