Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for gnu-coreutils commands instead of $OSTYPE #134

Closed
wants to merge 1 commit into from
Closed

Look for gnu-coreutils commands instead of $OSTYPE #134

wants to merge 1 commit into from

Conversation

ColinHebert
Copy link
Contributor

It's possible to have the gnu-coreutils on other environments than Linux

It's possible to have the gnu-coreutils on other environments than Linux
@sorin-ionescu
Copy link
Owner

What does dircolors have to do with du?

@ColinHebert
Copy link
Contributor Author

dircolors isn't defined in BSD-coreutils (AFAIK it's a GNU-coreutils specificity), so this allows to quickly check which coreutils is available. (I haven't tried any other form of coreutils yet).

But du is defined in every coreutils, so there are two solutions, either try to call du with the wrong options and catch the potential errors or trust dircolors.

@sorin-ionescu
Copy link
Owner

(( $+commands[dircolors] )) won't work anyway since it will be wrapped in a function in the case of the gnu-utils module. We need a more reliable way to detect GNU core utilities.

@sorin-ionescu
Copy link
Owner

There is a _pick_variant function in the man page.

@sorin-ionescu
Copy link
Owner

There is also grep -q -i GNU < <(du --version 2>&1).

@ColinHebert
Copy link
Contributor Author

I've seen a lot of attempts to define which version of coreutils is used. One of them is with strings on the executable, eg strings du contains the "GNU coreutils" string

@sorin-ionescu
Copy link
Owner

grep -q -i GNU < <(strings $(type -p du | cut -d' ' -f3-)) won't work with gnu-utility.

@ColinHebert
Copy link
Contributor Author

whence -p should give a better result than type -p (no need to cut it). But anyway, it doesn't help, we don't need the -p because it's not a file accessible in a path, it's a function.

lildude pushed a commit to lildude/prezto that referenced this pull request Jan 12, 2014
kodelint pushed a commit to kodelint/prezto that referenced this pull request Nov 15, 2016
…_substitution_highlighting

highlight ^old^new pattern
RIT80 pushed a commit to RIT80/prezto that referenced this pull request Jan 25, 2022
RIT80 added a commit to RIT80/prezto that referenced this pull request Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants