summaryrefslogtreecommitdiff
path: root/Biz/Ide/repl.bash
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-01 15:19:49 -0400
committerBen Sima <ben@bsima.me>2024-04-01 15:19:49 -0400
commit2d40ec3a03f4684f6fabba7dee2981c992a13785 (patch)
tree1edc1522fd5eb8e6d20b1b4dbde89f3e49ad9e51 /Biz/Ide/repl.bash
parentdb373a8c727cad91d375b40a6c70b11ed73bdafb (diff)
Rename .bash files to .sh
I was already using .sh to refer to shell scripts. When I added .bash, I didn't realize that the linter was set to act on .sh files and not .bash files, so all of these bash scripts escaped the linter. This commit renames them to .sh, removes the .bash extension support from Biz.Namespace, and fixes all the reported shellcheck errors.
Diffstat (limited to 'Biz/Ide/repl.bash')
-rwxr-xr-xBiz/Ide/repl.bash85
1 files changed, 0 insertions, 85 deletions
diff --git a/Biz/Ide/repl.bash b/Biz/Ide/repl.bash
deleted file mode 100755
index a14b0b8..0000000
--- a/Biz/Ide/repl.bash
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env bash
-###
-### a simple complement to bild which only deals with launching repls
-###
-### > repl [opts] <target..>
-###
-### Starts a repl/shell for one or more targets. (Currently, all targets must
-### have the same extension for this to work.) Repls started with this script
-### should bind to `localhost:$PORT`.
-###
-### Options:
-### --bash start bash instead of the target language repl
-help() {
- sed -rn 's/^### ?//;T;p' "$0"
-}
-if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
- help
- exit 1
-fi
-##
- set -e
- CMD=
- if [[ "$1" == "--bash" ]]; then
- CMD="bash"
- shift
- fi
- targets=${@:?}
- json=$(bild --plan ${targets[@]})
- langdeps=$(jq --raw-output '.[].langdeps | join(" ")' <<< $json)
- sysdeps=$(jq --raw-output '.[].sysdeps | join(" ")' <<< $json)
- rundeps=$(jq --raw-output '.[].rundeps | join(" ")' <<< $json)
- exts=$(jq --raw-output '.[].namespace.ext' <<< $json | sort | uniq)
- packageSet=$(jq --raw-output '.[].packageSet' <<< $json)
- module=$(jq --raw-output '.[].mainModule' <<< $json)
- BILD="(import ${CODEROOT:?}/Biz/Bild.nix {})"
- for lib in ${sysdeps[@]}; do
- flags+=(--packages "$BILD.pkgs.${lib}")
- flags+=(--packages "$BILD.pkgs.pkg-config")
- done
- for lib in ${rundeps[@]}; do
- flags+=(--packages "$BILD.pkgs.${lib}")
- done
- case $exts in
- C)
- flags+=(--packages "$BILD.pkgs.gcc")
- command="bash"
- ;;
- Hs)
- if [ -z ${var+PORT} ]; then
- echo "warn: repl: ghci does not support binding to a port"
- fi
- flags+=(--packages "$BILD.bild.haskell.ghcWith (h: with h; [$langdeps])")
- command=${CMD:-"ghci -i${CODEROOT:?} -ghci-script ${CODEROOT:?}/.ghci ${targets[@]}"}
- ;;
- Scm)
- for lib in ${langdeps[@]}; do
- flags+=(--packages "$BILD.guile-${lib}")
- done
- flags+=(--packages "$BILD.guile")
- command=${CMD:-"guile -L ${CODEROOT:?} -C ${CODEROOT:?}/_/int --r7rs --listen=${PORT:-37146}"}
- ;;
- Lisp)
- flags+=(--packages "$BILD.bild.$packageSet (p: with p; [asdf swank $langdeps])")
- command=${CMD:-"sbcl --eval '(require :asdf)' --eval '(require :swank)' --eval '(swank:create-server :port ${PORT:-4005})' --load $targets"}
- ;;
- Rs)
- flags+=(--packages "$BILD.nixpkgs.rustc")
- command=bash
- ;;
- Py)
- langdeps="$langdeps mypy"
- flags+=(--packages ruff)
- flags+=(--packages "$BILD.bild.python.pythonWith (p: with p; [$langdeps])")
- PYTHONPATH=$CODEROOT:$PYTHONPATH
- pycommand="python -i $CODEROOT/Biz/Repl.py $module ${targets[@]}"
- command=${CMD:-"$pycommand"}
- ;;
- *)
- echo "unsupported targets: ${targets[@]}"
- exit 1
- ;;
- esac
-##
- nix-shell "${flags[@]}" --command "$command"
-##