From 8bba26aed67db60df7067762673b3d828f01d187 Mon Sep 17 00:00:00 2001 From: Qubut Date: Thu, 24 Oct 2024 02:01:25 +0200 Subject: [PATCH] fix(grimshot): resolve missing functional-helpers file error (#40) - Fixed issue where the script failed to source the functional-helpers file. By including it's functionality in the script itself Closes #40. --- grimshot/functional-helpers | 33 --------------------------------- grimshot/grimshot | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 34 deletions(-) delete mode 100755 grimshot/functional-helpers diff --git a/grimshot/functional-helpers b/grimshot/functional-helpers deleted file mode 100755 index dcd2213..0000000 --- a/grimshot/functional-helpers +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh -when() { - condition=$1 - action=$2 - - if eval "$condition"; then - eval "$action" - fi -} - -whenOtherwise() { - condition=$1 - true_action=$2 - false_action=$3 - - if eval "$condition"; then - eval "$true_action" - else - eval "$false_action" - fi -} - -any() { - for tuple in "$@"; do - condition=$(echo "$tuple" | cut -d: -f1) - action=$(echo "$tuple" | cut -d: -f2-) - if eval "$condition"; then - eval "$action" - return 0 - fi - done - return 1 # No conditions matched -} diff --git a/grimshot/grimshot b/grimshot/grimshot index 78d216a..e0dd7b7 100755 --- a/grimshot/grimshot +++ b/grimshot/grimshot @@ -11,7 +11,40 @@ ## Those are needed to be installed, if unsure, run `grimshot check` ## ## See `man 1 grimshot` or `grimshot usage` for further details. -. ./functional-helpers + +when() { + condition=$1 + action=$2 + + if eval "$condition"; then + eval "$action" + fi +} + +whenOtherwise() { + condition=$1 + true_action=$2 + false_action=$3 + + if eval "$condition"; then + eval "$true_action" + else + eval "$false_action" + fi +} + +any() { + for tuple in "$@"; do + condition=$(echo "$tuple" | cut -d: -f1) + action=$(echo "$tuple" | cut -d: -f2-) + if eval "$condition"; then + eval "$action" + return 0 + fi + done + return 1 # No conditions matched +} + NOTIFY=no CURSOR=