Improve comments

This commit is contained in:
tsi 2026-01-03 01:29:15 +01:00
parent 0593b06daf
commit 342d792a9d
No known key found for this signature in database

View file

@ -223,7 +223,7 @@ _try_abbrev_internal () {
# [[ $point -eq ${#line} || "${line:point:1}" = ["${_bash_meta_chars[*]}"] ]] && # [[ $point -eq ${#line} || "${line:point:1}" = ["${_bash_meta_chars[*]}"] ]] &&
# NOTE: Above line commented out, it's actually not that useful. # NOTE: Above line commented out, it's actually not that useful.
# Determine word to complete # Determine word to complete by stripping leading shell metacharacters
# Uses the same word separators as bash (| & ; ( ) space tab newline) (aka "shell metacharacters") # Uses the same word separators as bash (| & ; ( ) space tab newline) (aka "shell metacharacters")
# But < and > are ignored, since they always expect a file/delimiter/string afterwards and not a command # But < and > are ignored, since they always expect a file/delimiter/string afterwards and not a command
declare -r word_at_point=${line_until_point##*["${_bash_meta_chars_without_left_right_angle_brackets[*]}"]} && declare -r word_at_point=${line_until_point##*["${_bash_meta_chars_without_left_right_angle_brackets[*]}"]} &&
@ -306,16 +306,19 @@ _try_abbrev_internal () {
fi fi
# Advance mark if it's set and right of (or on) the point. # Advance mark if it's set and right of (or on) the point.
[[ $mark && mark -ge point ]] && eval "$new_mark"'=$((mark+offset))' [[ $mark && mark -gt point ]] && eval "$new_mark"'=$((mark+offset))'
[[ -v "$new_mark" ]] || eval "$new_mark"'=$mark'
# Advance point. # Advance point.
eval "$new_point"'=$((point+offset))' eval "$new_point"'=$((point+offset))'
# NB: READLINE_ARGUMENT is deliberately ignored. # NB: READLINE_ARGUMENT is deliberately ignored, as it doesn't make sense for interactive alias expansion.
} }
_try_abbrev () { _try_abbrev () {
# For use within bind -x. # For use within bash's bind -x builtin.
# Perform abbreviation lookup and interactive expansion on the word left to the cursor (no quote parsing). # Perform interactive alias expansion on the word left to the cursor (no quote parsing) and also *on* the cursor if the
# Takes a single argument which is the character to self-insert (usually space or another shell metacharacter). # self-insertion character is empty (which represents pressing enter).
# Takes a single argument which is the character to self-insert (usually space or another shell metacharacter, or empty for newline/enter).
# To prevent infinite recursion, we need to keep track # To prevent infinite recursion, we need to keep track
# of which aliases have been expanded. This function re-initializes the global associative array (used as a hash set) # of which aliases have been expanded. This function re-initializes the global associative array (used as a hash set)