From 0f0161214575e98eeb8743536b1a52fd9d06a924 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 5 Jul 2022 12:41:16 +0200 Subject: [PATCH] fix: cascade failures --- handlers/script/install | 4 ++-- instalee | 19 ++++++++++++++----- packages/logcli/script | 7 ++++--- 3 files changed, 20 insertions(+), 10 deletions(-) mode change 100644 => 100755 packages/logcli/script diff --git a/handlers/script/install b/handlers/script/install index 9f37312..b3916c4 100755 --- a/handlers/script/install +++ b/handlers/script/install @@ -1,10 +1,10 @@ -#!/bin/sh +#!/bin/sh -e arg=$1 name=$2 location="/usr/local/bin/${name:-$(basename "$arg")}" case "$arg" in (*://*) curl "$arg" | sudo tee "$location" > /dev/null;; - (*) cp "$arg" "$location";; + (*) sudo cp "$arg" "$location";; esac sudo chmod +x "$location" test "$INSTALEE_VERBOSE" -lt 3 || echo "Installed $name to $location" diff --git a/instalee b/instalee index fc51a8d..397131e 100755 --- a/instalee +++ b/instalee @@ -8,7 +8,12 @@ highlight() { echo "$1"; } destress() { echo "$1"; } # Get the content of a file or the output of its execution -getcontent() { test -x "$1" && "$1" || cat "$1"; } +getcontent() { + if test -x "$1" + then "$1" + else cat "$1" + fi +} # Get available package entries for given package getentries() { @@ -35,6 +40,7 @@ installpkg() { fi for pkg in $pkgs do highlight "$pkg" + set -e local name="$(basename $pkg)" local base="${name%_*}" @@ -42,10 +48,13 @@ installpkg() { local handler="$home/handlers/$base" if test -d "$handler" then - local args="$(getcontent "$pkg" | grep . || echo "$1")" - local install="$(find "$handler" -name "install$ext" | head -1)" && - destress " $install $args" && - $install $args + # This declaration needs to be ahead, otherwise it overrides failing exit codes + local args install + args="$(getcontent "$pkg")" + args="${args:-$1}" + install="$(find "$handler" -name "install$ext" | head -1)" + destress " $install $args" + $install $args else destress " running unhandled $pkg" $pkg diff --git a/packages/logcli/script b/packages/logcli/script old mode 100644 new mode 100755 index ee06a47..917d684 --- a/packages/logcli/script +++ b/packages/logcli/script @@ -1,5 +1,6 @@ +#!/bin/sh -e cd /tmp -git clone https://github.com/grafana/loki.git +git clone https://github.com/grafana/loki.git || true cd loki -make logcli -cmd/logcli/logcli +make logcli >&2 +echo "$PWD/cmd/logcli/logcli"