Skip to content

Commit b91bdf3

Browse files
committed
l: use more portable grep invocations
fgrep and egrep are available on Solaris 11 at least, while grep -F and grep -E are not.
1 parent 1d9f9a4 commit b91bdf3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • scripts

scripts/l

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ESC=`printf '\033'`
4242
if ! tput setaf 1 >/dev/null 2>&1 && ! tput AF 1 >/dev/null 2>&1; then
4343
color_when=
4444
# enable highlighting if outputting to terminal or forcing
45-
elif test -t 1 || echo "$*" | grep -E -- "--color( |=always|$)" >/dev/null; then
45+
elif test -t 1 || echo "$*" | egrep -- "--color( |=always|$)" >/dev/null; then
4646
# Note if the user specifies --color=auto then that will override this
4747
# and hence the output will not be colored :(
4848
color_when=always
@@ -101,9 +101,9 @@ if [ "$color_when" ]; then
101101

102102
# Newer ls use "mh" to represent the color for multi hardlinked
103103
# files so handle the backwards incompatibility with "hl"
104-
if dircolors | grep -F ":mh=" >/dev/null; then
104+
if dircolors | fgrep ":mh=" >/dev/null; then
105105
hl_no_color="s/:hl=[^:]*:/:mh=:/; s/:mh=[^:]*:/:mh=:/"
106-
elif dircolors | grep -F "hl=" >/dev/null; then
106+
elif dircolors | fgrep "hl=" >/dev/null; then
107107
hl_no_color="s/:mh=[^:]*:/:hl=:/; s/:hl=[^:]*:/:hl=:/"
108108
fi
109109

@@ -142,7 +142,7 @@ $ls --quoting=shell-escape -d . >/dev/null 2>&1 && quote=--quoting=shell-escape
142142
# Bypass long format manipulation if any of following formats are specified
143143
# FIXME: Matching options like this is a bit brittle
144144
lfmt=lfmt
145-
echo "$*" | grep -E -- "-(m|i|x|s|C|-version|-help)" >/dev/null && lfmt=""
145+
echo "$*" | egrep -- "-(m|i|x|s|C|-version|-help)" >/dev/null && lfmt=""
146146

147147
# set -o pipefail is bash/ksh/zsh specific
148148
# So manually propagate the exit status from ls.

0 commit comments

Comments
 (0)