Skip to content

Check for ls flavor in .aliases is no longer correct #1063

@djotto

Description

@djotto
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
	colorflag="--color"
	export LS_COLORS=[...]
else # macOS `ls`
	colorflag="-G"
	export LSCOLORS=[...]
fi

At some point, the macOS version of ls started understanding the --color flag (I'm on 14.4.1)

I propose this instead, but I can't test it against earlier versions of macOS:

if ls --help > /dev/null 2>&1; then
   echo "GNU ls";
else
   echo "MacOS ls";
fi;

PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions