about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-12-28 20:03:16 +0100
committerSoispha <soispha@vhack.eu>2023-12-28 20:03:16 +0100
commit04d128b17292131f5444ae58d8ef43b31664ac06 (patch)
tree1ff59fd2f52eae5dabe649278e1b30f469321f1e
parentfix(hm/pkgs/src/neorg/project): Exit instead of doing something different (diff)
downloadnixos-config-04d128b17292131f5444ae58d8ef43b31664ac06.tar.gz
nixos-config-04d128b17292131f5444ae58d8ef43b31664ac06.zip
fix(hm/pkgs/src/neorg): Fix exit from subshell
Diffstat (limited to '')
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/neorg/neorg15
1 files changed, 11 insertions, 4 deletions
diff --git a/hm/soispha/pkgs/scripts/wrappers/neorg/neorg b/hm/soispha/pkgs/scripts/wrappers/neorg/neorg
index 2c3736f9..a34eefa5 100755
--- a/hm/soispha/pkgs/scripts/wrappers/neorg/neorg
+++ b/hm/soispha/pkgs/scripts/wrappers/neorg/neorg
@@ -62,6 +62,13 @@ ARGUMENTS:
 
 EOF
 }
+
+
+# Runs it's first argument and then the second, regardless if the first failed or succeed
+chain() {
+    eval "$1"; eval "$2"
+}
+
 # Utils {{{
 UTILS_get_current_context() {
     current_context="$(task _get rc.context)";
@@ -191,7 +198,7 @@ DMENU_open_context_in_browser() {
         PROJECT_open_context_in_browser "$project";
     else
         current_context="$(UTILS_get_current_context)";
-        [ "$current_context" ] || (notify-send "(Neorg) No current context"; exit 1)
+        [ "$current_context" ] || chain 'notify-send "(Neorg) No current context"' "exit 1"
         PROJECT_open_context_in_browser "$current_context";
     fi
 }
@@ -250,7 +257,7 @@ while [ "$#" -ne 0 ]; do
         "t"*) # task
             shift 1;
             task_id="$1";
-            [ "$task_id" ] || (CONTEXT_open_current_task_context; exit 0);
+            [ "$task_id" ] || chain CONTEXT_open_current_task_context "exit 0"
             CONTEXT_open_current_task_context_at_task_id "$task_id";
             exit 0;
             ;;
@@ -258,7 +265,7 @@ while [ "$#" -ne 0 ]; do
             shift 1;
             workspace_to_open="$1";
             # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
-            [ "$workspace_to_open" ] || (WORKSPACE_open_neorg_workspace_prompt; exit 0);
+            [ "$workspace_to_open" ] || chain WORKSPACE_open_neorg_workspace_prompt "exit 0";
             WORKSPACE_open_neorg_workspace "$workspace_to_open";
             exit 0;
             ;;
@@ -266,7 +273,7 @@ while [ "$#" -ne 0 ]; do
             shift 1;
             context_to_open="$1";
             # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
-            [ "$context_to_open" ] || (PROJECT_open_current_context_in_browser; exit 0);
+            [ "$context_to_open" ] || chain PROJECT_open_current_context_in_browser "exit 0";
             if ! grep -q "$context_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then
                 die "Your context ('$context_to_open') is not in the list of available contexts:
 %ALL_PROJECTS_COMMA";