Skip to content

Commit

Permalink
Fix tarball url parsing in presence of "pipefail"
Browse files Browse the repository at this point in the history
Piping to `head` does not mix with `set -o pipefail` because `head` "short-circuits" as soon as it finds a result, causing a SIGPIPE to be sent to the writer, which may cause the writer to fail.
  • Loading branch information
eatdrinksleepcode authored and pgrange committed Mar 19, 2024
1 parent 5f15e80 commit 30b5918
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set -euo pipefail

echo "downloading bash_unit"
current_working_dir=$PWD
tarball_url=$(curl -s https://api.github.com/repos/pgrange/bash_unit/releases | grep tarball_url | head -n 1 | cut -d '"' -f 4)
tarball_urls=$(curl -s https://api.github.com/repos/pgrange/bash_unit/releases | grep tarball_url)
tarball_url=$(echo "$tarball_urls" | head -n 1 | cut -d '"' -f 4)
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'tmpdir')
cd "$tmp_dir" || exit
curl -Ls "$tarball_url" | tar -xz -f -
Expand Down

0 comments on commit 30b5918

Please sign in to comment.