From 31ad7d7c28b5852359446d21abaf44d400079a60 Mon Sep 17 00:00:00 2001 From: tsi Date: Thu, 25 Dec 2025 20:48:22 +0100 Subject: [PATCH] Use [:blank:] when appropriate --- bash-abbr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bash-abbr b/bash-abbr index bba3d29..fcfbf80 100644 --- a/bash-abbr +++ b/bash-abbr @@ -119,7 +119,7 @@ _control_op () { _bg_proc_or_and_and='[^&;]&&?' \ _pipe_or_or_or='[^&|;]\|\|?' \ _semicolon_or_case_operators='[^;|];;?&?' \ - _opening_paren='(^|[^[:alnum:]])\(' + _opening_paren='(^|[^[:alnum:]])\(' declare _control_op="^" _control_op+="|$_newline" _control_op+="|$_bg_proc_or_and_and" @@ -140,7 +140,7 @@ _redir_or_assign_word () { _redir_or_append_out_and_err='(&)(>>?)' \ _heredoc_herestring_in_out_etc='>>?|<(>|<(-?|<))?' \ _identifier_equals='[[:alpha:]_][[:alnum:]]*=' \ - _simple_unquoted_word='[^[:space:]<>&;()|'\''"`$]+' \ + _simple_unquoted_word='[^[:blank:]<>&;()|'\''"`$]+' \ _double_quoted_string='\$?"([^"]|\\")*"' \ _single_quoted_string="\\\$?'[^']*'" \ _backtick_string='`([^`]|\\`)*`' \ @@ -164,17 +164,17 @@ _redir_or_assign_word () { _close_redirection="($_varredir_or_number)($_redir_in_or_out)($_close_or_move_fd)" \ _generic_redirection="($_redir_or_append_out_and_err|($_varredir_or_number)($_heredoc_herestring_in_out_etc))" # shellcheck disable=SC1087 - declare -r _word_redirection_or_assignment="($_generic_redirection[[:space:]]*|$_identifier_equals)($_word)" + declare -r _word_redirection_or_assignment="($_generic_redirection[[:blank:]]*|$_identifier_equals)($_word)" printf %s "$_close_redirection|$_word_redirection_or_assignment" unset -f _redir_or_assign_word } # shellcheck disable=SC2155 declare -r _redir_or_assign_word="$(_redir_or_assign_word)" # TODO use bash 5.3 `${}` command substitution syntax to avoid subshells -declare -r is_first_word_prefix="($_control_op)[[:space:]]*((($_redir_or_assign_word)[[:space:]])*)" +declare -r is_first_word_prefix="($_control_op)[[:blank:]]*((($_redir_or_assign_word)[[:blank:]])*)" # If the regex leads to problems/performance issues, you may try this simpler regex # that does no redirection/assignment word checking: -# declare -r is_first_word_prefix="($_control_op)[[:space:]]*" +# declare -r is_first_word_prefix="($_control_op)[[:blank:]]*" unset -v _control_op @@ -259,7 +259,7 @@ _try_abbrev_internal () { # Recursively expand replacement if we haven't expanded it already declare tmp=" $replacement" # Prepend space, makes the logic easier - [[ $tmp =~ ^([[:space:]]*$is_first_word_prefix) ]] && tmp=${tmp#"${BASH_REMATCH[1]}"} # Strip matching prefix + [[ $tmp =~ ^([[:blank:]]*$is_first_word_prefix) ]] && tmp=${tmp#"${BASH_REMATCH[1]}"} # Strip matching prefix declare -r word_to_expand=${tmp%%[<>&;()|[:space:]]*} if [[ -z ${_expanded_aliases[$word_to_expand]-} ]]; then declare -r point_for_replacement=$((${#BASH_REMATCH[1]}+${#word_to_expand}))