From b676318ae3c6fc6a94b605eeb3957b5b5148a236 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 24 Feb 2021 14:19:30 +0000 Subject: [PATCH] x: extend so `x --root` returns the root of the workspace Signed-off-by: Alejandro Mery --- files/bin/x | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/files/bin/x b/files/bin/x index 215c2ac..61906b5 100755 --- a/files/bin/x +++ b/files/bin/x @@ -58,7 +58,18 @@ find_run_sh() { } run_sh="$(find_run_sh)" -if [ -x "$run_sh" ]; then + +if test "x--root" = "x${1:-}"; then + + if [ -x "$run_sh" ]; then + # found + echo "$(dirname "$run_sh")" + exit 0 + fi + + # failed to find workspace + exit 1 +elif [ -x "$run_sh" ]; then exec "$run_sh" "$@" elif [ "$#" -gt 0 ]; then exec "$@"