summaryrefslogtreecommitdiff
path: root/wrapper/inner.sh.m4
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper/inner.sh.m4')
-rw-r--r--wrapper/inner.sh.m425
1 files changed, 20 insertions, 5 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() {