aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d/ls.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/profile.d/ls.sh')
-rw-r--r--sh/profile.d/ls.sh26
1 files changed, 18 insertions, 8 deletions
diff --git a/sh/profile.d/ls.sh b/sh/profile.d/ls.sh
index 25fe4777..3ecaa5fd 100644
--- a/sh/profile.d/ls.sh
+++ b/sh/profile.d/ls.sh
@@ -1,9 +1,19 @@
-# Define and store appropriate colors for ls
-if command -v dircolors >/dev/null 2>&1 ; then
- if [ -r "$HOME"/.dircolors ] ; then
- eval "$(dircolors --sh -- "$HOME"/.dircolors)"
- else
- eval "$(dircolors --sh)"
- fi
-fi
+# Store ls(1)'s --help output in a variable
+lshelp=$(ls --help 2>/dev/null)
+
+# Define and store appropriate colors for ls(1) if applicable
+case $lshelp in
+ *--color*)
+ if command -v dircolors >/dev/null 2>&1 ; then
+ if [ -r "$HOME"/.dircolors ] ; then
+ eval "$(dircolors --sh -- "$HOME"/.dircolors)"
+ else
+ eval "$(dircolors --sh)"
+ fi
+ fi
+ ;;
+esac
+
+# We're done parsing ls(1)'s --help output now
+unset -v lshelp