Skip to content

Commit

Permalink
Fix issues with starting sponge
Browse files Browse the repository at this point in the history
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 meaningful-ooo#4.
  • Loading branch information
halostatue committed Jan 21, 2024
1 parent 3842995 commit c2c45d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 19 additions & 13 deletions functions/_sponge_on_postexec.fish
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
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
if set --local index (contains --index -- $_sponge_current_command $_sponge_queue)
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
4 changes: 2 additions & 2 deletions functions/sponge_filter_failed.fish
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c2c45d8

Please sign in to comment.