-
-
Notifications
You must be signed in to change notification settings - Fork 329
Does gix-command
mean for $0
to be --
?
#1840
-
When The argument after Because the arguments before But this sh -c command_string [command_name [argument...]] Where, as the standard documents for
This is to say that the effect of our passing
It seems to me that giving the script the name of If the goal of using However, we do have to pass something where we are currently passing I'm not sure what would be better. In one-liners and causal use, I think |
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment · 9 replies
-
Thanks for bringing this up! I also ran into the With that said, what I tried to do but somehow failed is to implement what Git does: /*
* If we have no extra arguments, we do not even need to
* bother with the "$@" magic.
*/
if (!argv[1])
strvec_push(out, argv[0]);
else
strvec_pushf(out, "%s \"$@\"", argv[0]);
```
It doesn't look like both implementations are very similar as `gix-command` allows passing additional arguments.
I think it's OK to not look at Git here and instead decide to use a more standard "no $0 available" name, and replacing `--` with `_` seems like the way to go.
I'd definitely appreciate a PR for that 🙏. |
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't follow (or don't agree). Both gitoxide/gix-command/src/lib.rs Lines 288 to 303 in b310c16
This code (intentionally) implements some functionality absent in Git. But both pass arguments through so they are usable as shell script positional parameters. In that strvec_pushv(out, argv); That runs on all code paths (except when the This is to say that, where However, that's the behavior I argued against above, on the grounds that it causes the origin of messages to be unclear, because someone examining stderr cannot tell if a message came from the shell or the external command the shell ran. It seems to me that this reasoning applies to Git, so that it may be a bug that Git does this, and even if it is not a bug, a different behavior might be an improvement. But Git might reasonably do it if it is somehow expected for backward compatibility, if some important software somehow relies on it, or if it turns out to be the most informative behavior in practice. Without knowing why this was chosen in Git--if it was chosen, since it's a very intuitive way to write the code, even though the effect is misleading--it would be hard to know if there are reasons for That is no argument against your concrete recommendation of using
Some possible approaches:
Finally, for each of those approaches, there is also the composite approach of doing it by default, but adding a field to The only disadvantage I am aware of that is added by allowing
In that experiment, the way I caused shells' own Furthermore, specifying a custom I say that not to argue that Refraining from adding a new field to |
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
Thanks for the clarification! Additionally, I agree that Thanks to your exhaustive analysis I also see and agree that using the shell path itself seems like what shells do, while solving a lot of problems. This seems like something that could easily be implemented, is it something you would be interested in? Regarding making |
Beta Was this translation helpful? Give feedback.
All reactions
-
I am not sure which approaches are more conventional. The approach of using the name used to invoke the shell matches what the shell does when the only argument after
It solves the Here's an example of what an error of this form--though with a different cause--currently looks like when it occurs on Windows (where the
Under the proposed change, that would probably become:
This seems like an improvement to me, still. In particular, no one is going to think
Yes, I will do this. Although the change itself should be easy, perhaps even requiring only a single line of code to be changed, we do not have tests for the case of
This should automatically work, but I think we need to cover at least
So far, so good. The problem is that even the tests of This should be feasible to fix one way or another, even without yet improving the behavior of the code under test:
EliahKagan@0d1ac8e is what I have so far for testing the behavior that should not change under the forthcoming change. The commit message states the above ideas in a way that may be clearer, I am not sure. (Once the tests pass on all platforms, I'll convert them to be more compact by using The
That's not very informative. It might be failing in the same way as
That is identical to the path munging that occurred for fixture scripts when running the test suite in most local Windows environments from PowerShell rather than Git Bash, prior to #1712. But it is not affected by the environment in which the new tests on that feature branch are run (nor would I expect that). Although it's tempting to interpret the less informative output from Note Updated information on this, related to the subsequent commit EliahKagan@387da88: The causes are different. The On Windows, paths that start with a single Instead, I can figure out whether it's reasonable to skip the If we are agreed on what the change in I can convert it to an issue (I'm just waiting for clarification that we agree on the fundamentals of what kind of change would fix it), though I don't think I can assign it to myself.
I certainly have no objection to omitting this additional functionality for now, and I agree it may not ever be needed. However, while this is not in any way an argument for adding that feature--actually it is something of an argument against it--please note that the experiment I showed above, running various shells with Edit: Returning to this and rereading what you've said, I think we are actually on the same page about this, and that what you meant by "it seems to" is that it may appear wrongly to have this effect, rather than that it seems to you or me that it does. The rest of this comment is about interpretation of the experiment with various shells in #1840 (reply in thread). It seems potentially valuable, so I've kept it in, even though it may not be needed for purposes of clarification as I had thought when I wrote it.
The tests with other shells are analogous, and show the same results, but look different because the other shells tested place |
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, that's even better, as it additionally avoids getting overly long.
Great, thanks!
There is
This seems like a reliable approach, and I am surprised this doesn't already happen - usually I try to avoid absolute paths.
Please do go ahead and create the issue with whatever solution for
Actually I understood it wrongly, and it's good to know that I am sorry if I didn't capture all context and/or respond to each question I should have responded to, these days I am extra-short on time and race through everything. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Sounds good, I've created issue #1842 from this, and also added a summary of what I think is the most important information (across all comments here). Hopefully I will also manage to make a PR that closes it sometime soon. Please feel free to assign me to the issue if desired. You may also want to move the help-wanted label from here to there.
To clarify, these are actually the same approach. Both are with
Ah, okay--I'm glad I clarified further then. I will still refrain from adding
That's quite all right. Even if you were not able to give full attention to some parts, they remain available to refer back to if interested, or when the topics they relate to come up again. In addition, from #1815 (comment) it looks like you are continuing to notice and give feedback on the most important things. So while I hope everything is going okay, I have no complaints! In view of your being short on time, I have ordered my replies in this comment so that the parts that may not be of immediate interest are below, and I will not assume that you have specifically considered them unless you say so. (In particular, I will not assume, without checking, that you would agree with any future design decisions that might be based on any of the analysis below.)
I didn't find a method by that name, but it put me on the right path (pun intended) to: gitoxide/gix-path/src/convert.rs Lines 220 to 230 in b4fe425
I have this caveat in code on my feature branch, on a function that can possibly be eliminated in favor of using gitoxide/gix-command/tests/command.rs Lines 569 to 575 in 387da88
While the wording can definitely be improved, maybe I can add something along those lines to the
Two possibilities come to mind. I think you may be thinking of
My impression is that
The other crate that comes to mind (though not by kornelski) is
This does not mean
|
Beta Was this translation helpful? Give feedback.
All reactions
-
I see, thanks for the clarification.
That's very considerate and does make a difference! Everything is indeed alright, all my time goes to GitButler for now.
Yes, that was it! Thanks for jogging my memory 😅.
I have a feeling that this research, as it's done by you, would be useful for both |
Beta Was this translation helpful? Give feedback.
All reactions
-
That's good to hear! |
Beta Was this translation helpful? Give feedback.
All reactions
-
A correction: The relationship between the value of
This is in This doesn't necessarily mean we can't pass the actual Windows path used to run the shell as the command name argument. I think there are some other path transformations that could potentially cause a problem, but that's not the main thing I'm thinking about right now; it even more significantly affects positional parameters, and I hope to look into it separately, ideally sometime soon. Rather, this motivates a simpler design idea. The full Windows path may be unexpected because it would not be shown in shell scripts under other circumstances. Using only the last component of the path may be sufficient, may avoid confusion as well as other path-transformation problems, and is shorter. It reflects a choice of shell set via |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Yes, that's even better, as it additionally avoids getting overly long.
Great, thanks!