diff --git a/hsmw-highlight b/hsmw-highlight index a3166b4..dec58b9 100644 --- a/hsmw-highlight +++ b/hsmw-highlight @@ -222,7 +222,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( # in_array_assignment true between 'a=(' and the matching ')' # braces_stack: "R" for round, "Q" for square, "Y" for curly # mybuf, cdpath_dir are used in sub-functions - local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir + local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir cur_cmd # arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator # idx and end_idx are used in sub-functions # for this_word and next_word look below at commented integers and at state machine description @@ -381,6 +381,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( style=reserved-word # de facto a reserved word, although not de jure (( next_word = 1 )) elif (( this_word & 1 )) && (( in_redirection == 0 )); then # $arg is the command word + cur_cmd="$arg" if (( arg_type == 1 )); then style=precommand elif [[ "$arg" = "sudo" ]]; then @@ -613,8 +614,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( [[ -z $expanded_path ]] && return 1 [[ -e $expanded_path ]] && return 0 - # Search the path in CDPATH - for cdpath_dir in $cdpath ; do + # Search the path in CDPATH, only for CD command + [[ "$cur_cmd" = "cd" ]] && for cdpath_dir in $cdpath ; do [[ -e "$cdpath_dir/$expanded_path" ]] && return 0 done