refactor(guards): remove what-comments; document no-arg edge case in RETURNS

This commit is contained in:
2026-06-10 22:59:11 -04:00
parent cccef17031
commit 4c989a45c1
+4 -9
View File
@@ -24,32 +24,27 @@
# __fish_config_op_greeting # __fish_config_op_greeting
# #
# RETURNS # RETURNS
# 0 Component enabled (category explicitly truthy; or category unset # 0 Component enabled (category explicitly truthy; or category unset and master not falsy)
# and master truthy/unset/unrecognized) # 1 Component disabled (category explicitly falsy; or category unset and master falsy)
# 1 Component disabled (category explicitly falsy; or category unset # (no argument → category check returns 2/unset; master governs)
# and master explicitly falsy)
# #
# EXAMPLE # EXAMPLE
# if __fish_config_op_enabled __fish_config_op_aliases # if __fish_config_op_enabled __fish_config_op_aliases
# alias grep='grep --color=auto' # alias grep='grep --color=auto'
# end # end
function __fish_config_op_enabled --description 'Check whether an opinionated component category is enabled' function __fish_config_op_enabled --description 'Check whether an opinionated component category is enabled'
# Category variable checked first: an explicit value takes precedence over
# the master switch in both directions.
__fish_variable_check $argv[1] __fish_variable_check $argv[1]
set -l cat_status $status set -l cat_status $status
# Explicitly truthy → enabled regardless of master.
if test $cat_status -eq 0 if test $cat_status -eq 0
return 0 return 0
end end
# Explicitly falsy → disabled regardless of master.
if test $cat_status -eq 1 if test $cat_status -eq 1
return 1 return 1
end end
# Category unset (2) or garbage (3): fall through to master switch. # Status 3 (garbage) defers to master — an unrecognized value is not an opt-out.
__fish_variable_check __fish_config_opinionated __fish_variable_check __fish_config_opinionated
if test $status -eq 1 if test $status -eq 1
return 1 return 1