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

Add sort_list_named to sort an array variable in-place via nameref #27

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

jansorg
Copy link
Collaborator

@jansorg jansorg commented Jun 18, 2024

The added function sort_list_named uses a namref variable to reference a variable by name, given by $1.
This avoids the requirement of a global "list" variable, because list is only local in sort_list_named.

I'm planning to use this in #23 to sort the output of info variables.

I passed the sort.sh through shfmt, which explains the changes to formatting. Let me know if I should revert this.

@jansorg jansorg changed the title add sort_list_named to sort an array variable in-place via nameref Add sort_list_named to sort an array variable in-place via nameref Jun 18, 2024
This avoids the requirement of a global "list" variable.
@jansorg jansorg force-pushed the 5.2/sort-nameref branch from 67be92b to 2dcbd62 Compare June 18, 2024 15:50
Copy link
Collaborator

@rocky rocky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! - thanks

@rocky rocky merged commit d1d256f into bash-5.2 Jun 18, 2024
3 checks passed
@jansorg jansorg deleted the 5.2/sort-nameref branch June 18, 2024 15:51
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