Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: coloring a substitution




On 2022-11-09 00:19, Roman Perepelitsa wrote:
Try this instead:
   if [[ $scope_msg = 'BROAD'                  && $dirname = (#i)*$~1* ]] ||
      [[ $scope_msg = 'Case INsensitive TAME' && $dirname = (#i)$~1 ]] ||
      [[ $scope_msg = 'Case Sensitive WILD'      && $dirname = *$~1* ]] ||
      [[ $scope_msg = 'EXACT'                  && $dirname = $~1 ]]; then

That's in place Roman, works identically to mine and I'll keep it on your say so, but what are the fine points on why your lines are better?  I understand the '$~' now so that's accepted.  As I now have it:

NEW:
    if [[ "$scope_msg" = 'BROAD'                  && $dirname == (#i)*$~1* ]] \     || [[ "$scope_msg" = 'Case INsensitive TAME' && $dirname == (#i)$~1 ]] \     || [[ "$scope_msg" = 'Case Sensitive WILD'      && $dirname == *$~1* ]] \     || [[ "$scope_msg" = 'EXACT'                  && $dirname == $~1 ]]; then ; # Do nothing, we have a match.
    else cc[$aa]=    # Kill the line, it does not match.
    fi
OLD:
    if [[ "$scope_msg" = 'BROAD'                  && $dirname = (#i)*$1* ]] \
    || [[ "$scope_msg" = 'Case INsensitive TAME' && $dirname:u = $1:u ]] \
    || [[ "$scope_msg" = 'Case Sensitive WILD'      && $dirname =~ $1 ]] \
    || [[ "$scope_msg" = 'EXACT'                  && $dirname = $1 ]]; then ; # Do nothing, we have a match.
    else cc[$aa]=    # Kill the line, it does not match.
    fi


If this works, consider using more traditional names for these cases:

- case-insensitive partial
- case-insensitive full
- case-sensitive partial
- case-sensitive full

I'm having fun experimenting with these terms and no one but me will ever  read them so I amuse myself.  I like 'exact'.  'broad' is useless.  Yeah, 'full' and 'partial' are more standard and perfectly clear. Tx.






Messages sorted by: Reverse Date, Date, Thread, Author