summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-07-04T10·15+0100
committerVincent Ambo <tazjin@google.com>2019-07-04T10·15+0100
commitb2f40b6ed83244986f191fab92eb127f08e65508 (patch)
tree25d6ba0e92cf95ea65abfdf46e125120e35a4ec9
parent892493a4788a9843b1b71848e58554e445658d31 (diff)
fix(tools): Ensure dispatch script passes arguments correctly r/13
-rwxr-xr-xtools/bin/__dispatch.sh30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/bin/__dispatch.sh b/tools/bin/__dispatch.sh
index 7db75bf870f3..228091c52452 100755
--- a/tools/bin/__dispatch.sh
+++ b/tools/bin/__dispatch.sh
@@ -2,30 +2,30 @@
 # This script dispatches invocations transparently to programs instantiated from
 # Nix.
 #
-# To add a new tool, in
+# To add a new tool, insert it into the case statement below by setting `attr`
+# to the key in nixpkgs which represents the program you want to run.
 set -ueo pipefail
 
 readonly REPO_ROOT=$(git rev-parse --show-toplevel)
-readonly ARGS="$@"
 readonly TARGET_TOOL=$(basename $0)
 
-function nix_dispatch() {
-  local attr="${1}"
-  local result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
-
-  PATH="${result}/bin:$PATH"
-  if [ -z "${ARGS}" ]; then
-    exec "${TARGET_TOOL}"
-  else
-    exec "${TARGET_TOOL}" "${ARGS}"
-  fi
-}
-
 case "${TARGET_TOOL}" in
   git-appraise)
-    nix_dispatch "thirdParty.gitAppraise"
+    attr="thirdParty.gitAppraise"
+    ;;
+  bazel)
+    attr="bazel"
+    ;;
+  stylish-haskell)
+    attr="haskellPackages.stylish-haskell"
     ;;
   *)
     echo "The tool '${TARGET_TOOL}' is currently not installed in this repository."
+    exit 1
     ;;
 esac
+
+result=$(nix-build --no-out-link --attr "${attr}" "${REPO_ROOT}")
+PATH="${result}/bin:$PATH"
+
+exec "${TARGET_TOOL}" "${@}"