Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with starting sponge #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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