Skip to content

Copy the input slice in helper.SliceStringRemove()#8

Merged
DBX12 merged 1 commit intoDBX12:masterfrom
particleflux:fix-sliceStringRemove-modifying-original
Feb 9, 2026
Merged

Copy the input slice in helper.SliceStringRemove()#8
DBX12 merged 1 commit intoDBX12:masterfrom
particleflux:fix-sliceStringRemove-modifying-original

Conversation

@particleflux
Copy link
Contributor

The previous version did, while returning a separate slice as output, also modify the original input slice. Deleting an element there then led to empty strings in the "unload --all" loop, when the loop slice args was implicitly modified.
This, in the end, lead to errors on unload --all when attempting to delete profiles named "".

e.g.:

$ env-manager unload --all
Unloading all profiles: awsMain,tfMysqlShared80Dev,allProxy,tfMysqlAuthDev

args: []string{"awsMain", "tfMysqlShared80Dev", "allProxy", "tfMysqlAuthDev"}

Unloading profile: awsMain
args: []string{"tfMysqlShared80Dev", "allProxy", "tfMysqlAuthDev", ""}

Unloading profile: allProxy
args: []string{"tfMysqlShared80Dev", "tfMysqlAuthDev", "", ""}

Unloading profile: 
Error: profile name cannot be empty

Solved by copying the input slice.

The previous version did, while returning a separate slice as output,
also modify the original input slice. Deleting an element there then led
to empty strings in the "unload --all" loop, when the loop slice `args`
was implicitly modified.

Solved by copying the input slice.
@DBX12 DBX12 merged commit a2022c5 into DBX12:master Feb 9, 2026
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