Skip to content

rehash: simplify source.bash pipeline#3419

Merged
native-api merged 1 commit intopyenv:masterfrom
jakelodwick:source-bash-cleanup
Mar 10, 2026
Merged

rehash: simplify source.bash pipeline#3419
native-api merged 1 commit intopyenv:masterfrom
jakelodwick:source-bash-cleanup

Conversation

@jakelodwick
Copy link
Copy Markdown
Contributor

The source.bash rehash hook reads source.d/*.list files through a 5-element pipeline: cat | sort | uniq | sed | sed. This simplifies it to sort -u file | sed -e ... -e ...:

  • cat removed: sort -u accepts filename arguments directly
  • sort | uniqsort -u: standard idiom
  • Two sed invocations → one with combined expressions

Before:

for shim in $(cat "${BASH_SOURCE%/*}/source.d/"*".list" | sort | uniq | sed -e 's/#.*$//' | sed -e '/^[[:space:]]*$/d'); do

After:

for shim in $(sort -u "${BASH_SOURCE%/*}/source.d/"*".list" | sed -e 's/#.*$//' -e '/^[[:space:]]*$/d'); do

Same cleanup applied to conda.bash in #3151.

All existing tests pass.

The source.bash rehash hook reads source.d/*.list files through a
5-element pipeline (cat | sort | uniq | sed | sed). Simplified to
sort -u <files> | sed -e ... -e ...:

- cat removed -- sort accepts filenames directly
- sort | uniq replaced with sort -u
- two sed invocations merged into one with combined expressions

Same cleanup applied to conda.bash in pyenv#3151.
@jakelodwick jakelodwick requested review from a team as code owners March 9, 2026 23:28
@native-api native-api merged commit e985ffa into pyenv:master Mar 10, 2026
20 checks passed
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.

2 participants