From 11c7421af599aaa5ca7ad7fd900c1fe70b206229 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 11 Jul 2026 17:18:33 +0200 Subject: pkgs/sw: Support a nix specific swallow mode --- pkgs/by-name/sw/sw/sw.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'pkgs/by-name/sw') diff --git a/pkgs/by-name/sw/sw/sw.sh b/pkgs/by-name/sw/sw/sw.sh index 68dd6a75..a62bfcbb 100755 --- a/pkgs/by-name/sw/sw/sw.sh +++ b/pkgs/by-name/sw/sw/sw.sh @@ -14,15 +14,32 @@ throwup() { riverctl focus-previous-tags } -if [ -z "$*" ]; then - printf "ERROR: No arguments supplied\n" -elif ! command -v "$1" >/dev/null; then - printf "ERROR: Command '%s' does not exist\n" "$1" -else +swallow() { # Make sure that we actually `throwup`, when the command fails set +e eat && "$@" - throwup + + set -e +} + +if [ -z "$*" ]; then + printf "sw: No arguments supplied\n" + exit 2 +else + case "$1" in + "-n" | "--nix") + shift 1 + [ -z "$1" ] && { + printf "sw: --nix requires a nix installible\n" + exit 2 + } + swallow nix run "n#$1" + ;; + *) + swallow "$@" + ;; + esac + fi -- cgit v1.3.1