diff options
author | Dylan Araps <dylan.araps@gmail.com> | 2019-01-13 17:24:00 +0200 |
---|---|---|
committer | Dylan Araps <dylan.araps@gmail.com> | 2019-01-13 17:24:00 +0200 |
commit | 9d60244eab90b29b93fe89357d5725cfecd6ddd0 (patch) | |
tree | 9763e1dcc94114c7a563c024b4dc5d7ce5417949 | |
parent | 5a53c1535eff658776465045d08e0aab93e7c2df (diff) |
ls_colors: don't crash on non posix strings
-rwxr-xr-x | fff | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -207,7 +207,8 @@ print_line() { # Color files that end in a pattern as defined in LS_COLORS. # 'BASH_REMATCH' is an array that stores each REGEX match. - elif [[ $file_name =~ .*($ls_patterns)$ ]]; then + elif [[ $file_name =~ [a-zA-Z_][a-zA-Z0-9_]*$ && + $file_name =~ .*($ls_patterns)$ ]]; then # Dynamically use the variable 'file_${BASH_REMATCH[1]}' # which stores the color from LS_COLORS. file_ext="file_${BASH_REMATCH[1]}" |