Skip to content

Commit

Permalink
ref(template.sh): check exit code or size rather than stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Oct 30, 2023
1 parent a545917 commit a97ab86
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions _webi/template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ __bootstrap_webi() {
return 0
fi

if [ -n "$(command -v pkg_format_cmd_version)" ]; then
if command -v pkg_format_cmd_version > /dev/null; then
my_versioned_name="'$(pkg_format_cmd_version "$WEBI_VERSION")'"
else
my_versioned_name="'$pkg_cmd_name v$WEBI_VERSION'"
Expand All @@ -88,14 +88,13 @@ __bootstrap_webi() {
}

# Update symlinks as per $HOME/.local/opt and $HOME/.local/bin install paths.
# shellcheck disable=2120
webi_link() {
if [ -n "$(command -v pkg_link)" ]; then
if command -v pkg_link > /dev/null; then
pkg_link
return 0
fi

if [ -n "$WEBI_SINGLE" ] || [ "single" = "${1-}" ]; then
if test -n "${WEBI_SINGLE}"; then
rm -rf "$pkg_dst_cmd"
ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
else
Expand Down Expand Up @@ -489,7 +488,7 @@ __bootstrap_webi() {
}

_webi_enable_exec() {
if [ -n "$(command -v spctl)" ] && [ -n "$(command -v xattr)" ]; then
if command -v spctl > /dev/null && command -v xattr > /dev/null; then
# note: some packages contain files that cannot be affected by xattr
xattr -r -d com.apple.quarantine "$pkg_src" || true
return 0
Expand Down Expand Up @@ -585,7 +584,7 @@ __bootstrap_webi() {
# shellcheck disable=SC2034 # used in ${WEBI_PKG}/install.sh
pkg_dst_bin="$(dirname "$pkg_dst_cmd")"

if [ -n "$(command -v pkg_pre_install)" ]; then pkg_pre_install; else webi_pre_install; fi
if command -v pkg_pre_install > /dev/null; then pkg_pre_install; else webi_pre_install; fi

(
cd "$WEBI_TMP"
Expand All @@ -609,20 +608,20 @@ __bootstrap_webi() {
fi
(
cd "$WEBI_TMP"
if [ -n "$(command -v pkg_post_install)" ]; then pkg_post_install; else webi_post_install; fi
if command -v pkg_post_install > /dev/null; then pkg_post_install; else webi_post_install; fi
)

(
cd "$WEBI_TMP"
if [ -n "$(command -v pkg_done_message)" ]; then pkg_done_message; else _webi_done_message; fi
if command -v pkg_done_message > /dev/null; then pkg_done_message; else _webi_done_message; fi
)

echo ""
fi

webi_path_add "$HOME/.local/bin"
if [ -z "${_WEBI_CHILD-}" ] && [ -f "$_webi_tmp/.PATH.env" ]; then
if [ -n "$(cat "$_webi_tmp/.PATH.env")" ]; then
if test -s "$_webi_tmp/.PATH.env"; then
printf 'PATH.env updated with:\n'
sort -u "$_webi_tmp/.PATH.env" | while read -r my_new_path; do
echo " ${my_new_path}"
Expand Down

0 comments on commit a97ab86

Please sign in to comment.