From c2c45d85434a9889622c7deb157ecbeb14abe8f2 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Sat, 20 Jan 2024 21:34:08 -0500 Subject: [PATCH] Fix issues with starting sponge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I got the following error block after installing 1.1.0 on every new tab. ``` contains: Key not specified test: Unexpected argument type at index 1 = true -a true = true ^ ~/.config/fish/functions/sponge_filter_failed.fish (line 4): if test $previously_in_history = true -a $sponge_allow_previously_successful = true ^ in function 'sponge_filter_failed' with arguments '0 ""' called on line 14 of file ~/.config/fish/functions/_sponge_on_postexec.fish in function '_sponge_on_postexec' called on line 1 of file ~/.config/fish/config.fish in event handler: handler for generic event “fish_postexec” called on line 378 of file ~/.config/fish/config.fish ``` This fixes both issues. Everything else *appears* to work. This may address #4. --- functions/_sponge_on_postexec.fish | 32 +++++++++++++++++------------ functions/sponge_filter_failed.fish | 4 ++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/functions/_sponge_on_postexec.fish b/functions/_sponge_on_postexec.fish index 1d67935..9d97ac8 100644 --- a/functions/_sponge_on_postexec.fish +++ b/functions/_sponge_on_postexec.fish @@ -1,4 +1,9 @@ function _sponge_on_postexec --on-event fish_postexec + # Ignore empty commands + if test -n $_sponge_current_command + return + end + set --global _sponge_current_command_exit_code $status # Remove command from the queue if it's been added previously @@ -6,19 +11,20 @@ function _sponge_on_postexec --on-event fish_postexec set --erase _sponge_queue[$index] end - # Ignore empty commands - if test -n $_sponge_current_command - set --local command '' - # Run filters - for filter in $sponge_filters - if $filter \ - $_sponge_current_command \ - $_sponge_current_command_exit_code \ - $_sponge_current_command_previously_in_history - set command $_sponge_current_command - break - end + if ! test -n "$_sponge_current_command_previously_in_history" + set _sponge_current_command_previously_in_history false + end + + set --local command '' + # Run filters + for filter in $sponge_filters + if $filter \ + $_sponge_current_command \ + $_sponge_current_command_exit_code \ + "$_sponge_current_command_previously_in_history" + set command $_sponge_current_command + break end - set --prepend --global _sponge_queue $command end + set --prepend --global _sponge_queue $command end diff --git a/functions/sponge_filter_failed.fish b/functions/sponge_filter_failed.fish index be26e5d..85bee9e 100644 --- a/functions/sponge_filter_failed.fish +++ b/functions/sponge_filter_failed.fish @@ -1,11 +1,11 @@ function sponge_filter_failed \ --argument-names command exit_code previously_in_history - if test $previously_in_history = true -a $sponge_allow_previously_successful = true + if test "$previously_in_history" = true -a "$sponge_allow_previously_successful" = true return 1 end - if contains $exit_code $sponge_successful_exit_codes + if contains -- $exit_code $sponge_successful_exit_codes return 1 end end