-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
support multiple paths in pathmunge #1664
support multiple paths in pathmunge #1664
Conversation
5f2ab26
to
663d6ec
Compare
Well, this started out in the spirit of moving the go pathmunge wrapper logic to core, but as @davidpfarrell points out, in my haste I forgot that for each go path, I have to append something. So I'll leave this PR in case y'all want it, but I'm cool with closing it too. Let me know what you think! I'm not in a rush on this one. |
663d6ec
to
79ca9a7
Compare
assert_equal "${new_paths}:${old_path}" "${PATH}" | ||
} | ||
|
||
@test 'helpers: pathmunge: multiple paths, with space' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a negative test, where you're trying to add the same path segment twice, to show that it will only be added once...
Thanks for working through this! So is it OK to merge this as-is? I've seen that you made changes to |
Yeah. I'll add that negative test and address go in a follow-up PR. |
Considering how much effort you put into fleshing out the tests, I'd be inclined to keep this PR moving. |
Regarding walking the input list backwards: So
But
So an interesting question arises: Should processing
Or should the resulting path contain
I'm slightly inclined to think that the relative order should be maintained, as the user is likely expressing a preference to have Implementing this would require walking the list backward in the Maybe we can check for the A quick googling didn't show any built-in function to reverse a list, so maybe setting up [edit: Updated for brevity, typos] |
I would remove the
Bash (at least some versions) will allow you to mix the two. Most of the shells won't accept that (zsh 4.x and perhaps above will - for example). Some shells will accept function foo, but for maximum portability, you should always use:
Line 677 in f8ae03e
|
@ahmadassaf I tend to target bash specifics intentionally because this is a bash specific project. I'll take a look at this suggestion though. Edit: I would like to see an issue that tracks this pattern and purges it from the repo instead of addressing it at each PR. Contributors are going to base their new work on what is existing, and we mix every form possible in this project. |
Indeed - we have that pattern We should probably address that from a general perspective and document it in the contribution guidelines. @ahmadassaf - care to open an issue for that? |
Can do indeed .. also I have been working on a fork where I did a large-scale refactoring (but also introduced some very opinionated stuff in there). I can share that once am done these days and can happily cherry pick and move some stuff over in a series of PRs. the changes addresses some of the common bash pitfalls, ensure code style consistency in things like comments, function definitions, etc. |
I have not finished everything yet but you can have a look at where I am at now https://github.com/ahmadassaf/gaudi-bash Will be updating docs today but still need to work on themes and custom components some time later this week/weekend. I am by no means a bash expert but tried my best to work something that made sense to me, so I hope some of these decisions make sense to you as well :) The main changes in this repo are:
|
Wow, very impressive! I think that the best way for us to go through all of this effort is for you to cherry-pick specific changes and submit them as PRs here. This way we can make small incremental changes. Your opinions @nwinkler @cornfeedhobo ? |
HI All - This line of conversation is off track from the purpose of this PR. @ahmadassaf I recommend you create an issue to continue discussions on the work you're doing. Name the issue something like You can use your post above as the starting post of the issue. I look forward to further discussions on your efforts, but let's keep comments on this PR focused on Thanks! |
Thank you @davidpfarrell and @NoahGorny. I opened #1678 and looking forward to hearing your thoughts in there |
@davidpfarrell I got to thinking about this again and you seem interested, so I'm looking to bounce thoughts off you: I closed this for the time being because the second parameter is currently optional. I was thinking that a third option, which would require the inclusion of the second option as well, wouldn't be elegant. But here's the examples I wrote out and I'd like to know what you think about this.
|
Hi @cornfeedhobo,
My first thoughts are that its interesting, and since its an optional 3rd parameter, it shouldn't break any existing functionality. My next thoughts are: What is/are the use-cases for this? Some that come to mind are:
Additionally, we have:
I'd be interested in knowing/seeing a code example where delaying the suffix appending is either a requirement or a significant convenience. I don't think the additional code needed in the pathmunge function would be too much, but it might make the tests for the function noticeably more complex. Hope that helps! |
@davidpfarrell The first case would be the go plugin. It currently has a pathmunge wrapper handling this. Honestly, at this point, I've been trying to make bash-it happy for a week and need to get back to golang code, so I'm happy to scrap this entire train of thought and just leave pathmunge as it is, because I can't think of another real-world use case, only the same abstract ones you thought of. |
@davidpfarrell Yeah, I'm going to scrap this. Just not enough value for the time cost. Thanks again for taking a look. |
This PR seeks to add support for colon deliminated list to be passed to
pathmunge
and removes the specialized wrapper that was in the go plugin. Tests have beenupdatedadded accordingly.I'd like to adjust the pathmunge function description, but the words escape me - taking all suggestions.