Skip to content

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

Merged
indrajitr merged 1 commit intosorin-ionescu:masterfrom
indrajitr:gnu-util-tweak
May 21, 2021
Merged

utility: Detect GNU 'ls' before applying the relevant tweaks#1917
indrajitr merged 1 commit intosorin-ionescu:masterfrom
indrajitr:gnu-util-tweak

Conversation

@indrajitr
Copy link
Copy Markdown
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
Copy Markdown
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.

1 participant