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

utility: Detect GNU 'ls' before applying the relevant tweaks #1917

Merged
merged 1 commit into from
May 21, 2021

Conversation

indrajitr
Copy link
Collaborator

@indrajitr indrajitr commented May 6, 2021

Detect ls provided by GNU Core Utilities upfront before applying the relevant settings and aliases.

The revised logic takes the following aspects into consideration:

  • is-callable 'dircolors' is not a sufficient test for verifying if the ls in scope is also provided by GNU Core Utilities. ls can continue to be the one provided by BSD Core Utilities because of its precedence in $path.
  • The ls in scope anyway can be either GNU Utils provided or BSD Utils provided depending on either $path precedence, soft link (via ln -s), or wrapper function (via 'gnu-utility' module).
  • So instead of 'guessing' the possible one, just detect if it is from GNU Utils and apply the relevant settings and aliases.
  • Note that GNU prefixed ls (gls) is intentionally not honored in this case to avoid possible conflict/shadowing with other gls callable (can happen if 'git' module is used, for example). Besides, honoring gls would imply we honor other commands (like mv, rm etc.) to be consistent. We have a module gnu-utils dedicated for that after all.

Also closes #1752.

@indrajitr
Copy link
Collaborator Author

indrajitr commented May 7, 2021

Note: This is an alternative version of #1786. Discussion on #1786 can continue separately, this PR just streamlines detection of GNU ls.

@indrajitr indrajitr force-pushed the gnu-util-tweak branch 8 times, most recently from 3748e69 to 460c11e Compare May 14, 2021 04:15
Detect `ls` provided by GNU Core Utilities upfront before applying
the relevant settings and aliases.

The revised logic takes the following aspects into consideration:
- `is-callable 'dircolors'` is not a sufficient test for verifying if
  the `ls` in scope is _also_ provided by GNU Core Utilities. `ls` can
  continue to be the one provided by BSD Core Utilities because of its
  precedence in `$path`.
- The `ls` in scope anyway can be either GNU Utils provided or BSD Utils
  provided depending on either `$path` precedence, soft link (via
  `ln -s`), or wrapper function (via 'gnu-utility' module).
- So instead of '_guessing_' the possible one, just detect if it is from
  GNU Utils and apply the relevant settings and aliases.
- Note that GNU prefixed `ls` (`gls`) is intentionally not honored in
  this case to avoid possible conflict/shadowing with other `gls`
  callable (can happen if 'git' module is used, for example).
  Besides, honoring `gls` would imply we honor other commands (like
  `mv`, `rm` etc.) to be consistent. We have a module 'gnu-utils'
  dedicated for that after all.
@indrajitr indrajitr merged commit 424d4cb into sorin-ionescu:master May 21, 2021
@indrajitr indrajitr deleted the gnu-util-tweak branch May 21, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant