Skip to content

Commit 2dd98f0

Browse files
authored
Merge pull request #58 from Vonage/fix/sh_shell
fix: POSIX compatible script to install
2 parents da06414 + 6c95573 commit 2dd98f0

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ permissions:
2222
statuses: write
2323

2424
jobs:
25+
test-install-using-action:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
- name: Install Cloud Runtime CLI
31+
uses: ./
32+
- name: Verify installation
33+
run: vcr --version
34+
test-install-using-script:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
- name: Install Cloud Runtime CLI
40+
shell: sh
41+
run: ./script/install.sh
42+
- name: Verify installation
43+
run: vcr --version
2544
build-and-test:
2645
runs-on: macos-latest
2746
env:

script/install.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,33 @@ main() {
125125
# If system-wide fails, try user-local directories
126126
user_local_paths="$HOME/.local/bin:$HOME/bin:$HOME/.vcr/bin"
127127

128-
IFS=':' read -ra paths <<< "$user_local_paths"
129-
for user_path in "${paths[@]}"; do
128+
oldIFS=$IFS
129+
IFS=:
130+
set -- $user_local_paths
131+
IFS=$oldIFS
132+
133+
for user_path do
130134
if mkdir -p "$user_path" 2>/dev/null && mv "$tmp_dir/${vcr_binary}" "$user_path/vcr" 2>/dev/null; then
131135
echo "vcr was installed successfully to $user_path"
132136

133137
# Check if the path is already in PATH
134-
if ! echo ":$PATH:" | grep -q ":$user_path:"; then
135-
case $SHELL in
136-
/bin/zsh) shell_profile=".zshrc" ;;
137-
*) shell_profile=".bash_profile" ;;
138-
esac
139-
echo ""
140-
echo "⚠️ Warning: $user_path is not in your \$PATH"
141-
echo "Add the following to your \$HOME/$shell_profile:"
142-
echo " export PATH=\"$user_path:\$PATH\""
143-
echo ""
144-
echo "Then you can run: vcr --help"
145-
else
146-
echo "Run 'vcr --help' to get started"
147-
fi
138+
case ":$PATH:" in
139+
*":$user_path:"*)
140+
echo "Run 'vcr --help' to get started"
141+
;;
142+
*)
143+
case $SHELL in
144+
/bin/zsh) shell_profile=".zshrc" ;;
145+
*) shell_profile=".bash_profile" ;;
146+
esac
147+
echo ""
148+
echo "⚠️ Warning: $user_path is not in your \$PATH"
149+
echo "Add the following to your \$HOME/$shell_profile:"
150+
echo " export PATH=\"$user_path:\$PATH\""
151+
echo ""
152+
echo "Then you can run: vcr --help"
153+
;;
154+
esac
148155
exit 0
149156
fi
150157
done

0 commit comments

Comments
 (0)