Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 270efae

Browse files
committed
Add posix sh env script
This amounted taking the bash env script and removing its use of the `local` keyword and changing is extension to ".sh". This allows the dune binary distro to be used on machines with minimal shells such as the ash shell in the default environment on alpine linux. Also adds a test that runs shellcheck on env.sh to make sure it stays posix-compatible. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
1 parent a0bd1a8 commit 270efae

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
5+
shellcheck:
6+
name: "Run shellcheck on the shell env script"
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: "Install shellcheck"
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y shellcheck
14+
- name: "Run shellcheck on the shell env script"
15+
run: |
16+
# exclude warning for sourcing missing external file
17+
shellcheck --exclude=SC1091 extra/share/dune/env/env.sh extra/share/dune/env/env.bash

extra/share/dune/env/env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
__dune_env() {
4+
if [ "$#" != "1" ]; then
5+
echo "__dune_env expected 1 argument, got $#"
6+
return
7+
fi
8+
__dune_root="$1"
9+
10+
# Add dune to PATH unless it's already present.
11+
# Affix colons on either side of $PATH to simplify matching (based on
12+
# rustup's env script).
13+
case :"$PATH": in
14+
*:"$__dune_root/bin":*)
15+
# Do nothing since the bin directory is already in PATH.
16+
;;
17+
*)
18+
# Prepending path in case a system-installed dune needs to be overridden
19+
export PATH="$__dune_root/bin:$PATH"
20+
;;
21+
esac
22+
}

0 commit comments

Comments
 (0)