summaryrefslogtreecommitdiff
path: root/common.sh.in
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-06-08 22:30:19 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-06-08 23:03:05 -0400
commit8c67cad1f2bbcaabe23586643d670ba08f3d2a05 (patch)
tree812d0cba8c0d157d8c22b67093c8f6c8a3bcd099 /common.sh.in
parent482ff021e313131af25eb6c8d70bd4d414c32105 (diff)
Clean up. Mostly have error handling be a mode.
You probably want to ignore whitespace change when viewing this diff.
Diffstat (limited to 'common.sh.in')
-rw-r--r--common.sh.in22
1 files changed, 17 insertions, 5 deletions
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 <lukeshu@sbcglobal.net>
+# Copyright (C) 2013-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net>
#
# 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 <http://www.gnu.org/licenses/>.
+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