From 94cacc84d322429e70485dea49bb858f48aa26c8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 14 Mar 2016 21:26:47 -0400 Subject: stuff --- wrapper/inner.sh.m4 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'wrapper/inner.sh.m4') diff --git a/wrapper/inner.sh.m4 b/wrapper/inner.sh.m4 index b07199e..09c870d 100644 --- a/wrapper/inner.sh.m4 +++ b/wrapper/inner.sh.m4 @@ -25,13 +25,13 @@ declare -r varname_EXEC_PATH="${PACKAGE^^}_EXEC_PATH" declare -r program_name="$1"; shift - +# _() { if type gettext &>/dev/null; then TEXTDOMAINDIR=$localedir gettext "$pkgtextdomain" "$1"; else - echo "$1"; + printf '%s' "$1"; fi } @@ -46,9 +46,9 @@ sighandler_exit() { install_sighandlers() { set -E for signal in TERM HUP QUIT; do - trap "signalhandler_exit $signal '%s signal cought. Exiting...'" $signal + trap "sighandler_exit $signal '%s signal cought. Exiting...'" $signal done - trap 'signalhandler_exit INT "Aborted by user. Exiting..."' INT + trap 'sighandler_exit INT "Aborted by user. Exiting..."' INT trap 'kill -USR1 "$$"' ERR } @@ -74,9 +74,9 @@ _runcmd() { shopt -s nullglob local files=("${exec_path}"/modules/*/"$cmd") if [[ ${#files[@]} -eq 0 ]]; then - error 127 '%s: Not a %s command' "$cmd" "$PACKAGE" + error 127 'Command not found: %s'"$cmd" fi - files=("${files[@]#"${exec_path/modules/}"}") + files=("${files[@]#"${exec_path}/modules/"}") local tmpdir trap '[ -z "${tmpdir:-}" ] || rm -rf -- "$tmpdir"' EXIT @@ -90,7 +90,7 @@ _runcmd() { local cwd printf -v cwd '%q' "$PWD" - make -j1 \ + make -j1 --no-print-directory --quiet \ -f "$exec_path/runcmd.mk" \ -C "$tmpdir/output" \ CWD="$cwd" \ @@ -102,10 +102,11 @@ _runcmd() { } _repo() { - [[ $# -ne 0 ]] || errusage 1 'Usage: %q repo' + [[ $# -eq 0 ]] || errusage 1 'Usage: %q repo' if [ -z "${!varname_REPO:-}" ]; then # we aren't getting a value from then env local repo=".${PACKAGE,,}" + OLDPWD='' # [------can ascend-----] && ! [-not found repo--] while [ "$PWD" != "$OLDPWD" ] && ! [ -d "$PWD/$repo" ]; do cd .. @@ -124,22 +125,22 @@ _repo() { } _init() { - [[ $# -gt 1 ]] || errusage 1 'Usage: %q init [directory]' + [[ $# -le 1 ]] || errusage 1 'Usage: %q init [directory]' local dir="${1:-$PWD}" mkdir -p -- "$dir" cd "$dir" repo="$(_repo 2> /dev/null)" || true if [ -n "${repo:-}" ]; then - error 129 "Repository already exists at \`%s'" "$repo" + error 129 'Repository already exists: %s' "$repo" fi export "$varname_REPO=$PWD/.${PACKAGE,,}" - mkdir "${!varname_REPO}" + test -d "${!varname_REPO}" || mkdir "${!varname_REPO}" _runcmd init "$dir" } main() { install_sighandlers - [[ $# -ge 1 ]] || error 'No command specified';; + [[ $# -ge 1 ]] || error 2 'No command specified'; export "${PACKAGE^^}=$program_name" local cmd=$1; shift -- cgit v1.2.3-2-g168b