diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-03-14 22:26:05 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-03-14 22:26:05 -0400 |
commit | 6d386c6cfe3d04a3188b9d05b7656ffec2a8f51f (patch) | |
tree | 96764b24c8cf130d25ddfbcea3adc1b2293f0fa5 /wrapper | |
parent | 7190864de465c3c3b015540ca45c9d9bccb5b790 (diff) |
fixity fix
Diffstat (limited to 'wrapper')
-rw-r--r-- | wrapper/inner.sh.m4 | 25 | ||||
-rw-r--r-- | wrapper/runcmd.mk | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/wrapper/inner.sh.m4 b/wrapper/inner.sh.m4 index 09c870d..bd67f02 100644 --- a/wrapper/inner.sh.m4 +++ b/wrapper/inner.sh.m4 @@ -64,17 +64,25 @@ errusage() { } _runcmd() { - [[ $# -ge 1 ]] || errusage 1 'Usage: %q <command> [<args>]' + [[ $# -ge 1 ]] || errusage 1 'Usage: %q [<module>/]<command> [<args>]' + local mod='' local cmd=$1; shift local args_str='' [[ $# -eq 0 ]] || printf -v args_str '%q ' "$@" local exec_path="${!varname_EXEC_PATH:-$pkglibexecdir}" + if [[ "$cmd" == */* ]]; then + if ! [[ -f "${exec_path}/modules/$cmd" ]]; then + error 127 'Module/Command not found: %s' "$cmd" + fi + mod="${cmd%%/*}" + cmd="${cmd#*/}" + fi shopt -s nullglob local files=("${exec_path}"/modules/*/"$cmd") if [[ ${#files[@]} -eq 0 ]]; then - error 127 'Command not found: %s'"$cmd" + error 127 'Command not found: %s' "$cmd" fi files=("${files[@]#"${exec_path}/modules/"}") @@ -90,15 +98,22 @@ _runcmd() { local cwd printf -v cwd '%q' "$PWD" - make -j1 --no-print-directory --quiet \ + make --no-print-directory --quiet \ -f "$exec_path/runcmd.mk" \ -C "$tmpdir/output" \ CWD="$cwd" \ - ARGS="$args_str" \ + ARGS="${args_str//'$'/'$$'}" \ EXEC_PATH="$exec_path" \ TMPDIR="$tmpdir" \ -- "${files[@]}" - exit $? + local r=$? + cd "$tmpdir/output" + if [[ -n "$mod" ]]; then + cat "$mod/$cmd" + else + grep -r ^ * + fi + return $r } _repo() { diff --git a/wrapper/runcmd.mk b/wrapper/runcmd.mk index 40e791e..407ffdc 100644 --- a/wrapper/runcmd.mk +++ b/wrapper/runcmd.mk @@ -11,6 +11,6 @@ export OUTPUT_DIR := $(realpath .) $(MAKECMDGOALS): % : $(EXEC_PATH)/modules/% mkdir -p -- '$(@D)' - { (cd $(CWD) && '$<' $(ARGS)) | tee -- '$@' >&2; } 2>&1 | sed 's,^,$@:,' >&2 + +(cd $(CWD) && '$<' $(ARGS)) > '$@' include $(wildcard $(EXEC_PATH)/modules/*.mk) |