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

Fix up Command Debug output when arg0 is specified. #67219

Merged
merged 2 commits into from
Dec 20, 2019

Conversation

jsgf
Copy link
Contributor

@jsgf jsgf commented Dec 11, 2019

PR #66512 added the ability to set argv[0] on
Command. As a side effect, it changed the Debug output to print both the program and
argv[0], which in practice results in stuttery output ("echo" "echo" "foo").

This PR reverts the behaviour to the the old one, so that the command is only printed
once - unless arg0 has been set. In that case it emits "[command]" "arg0" "arg1" ....

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 11, 2019
@jsgf jsgf force-pushed the command-argv0-debug branch 2 times, most recently from e16d731 to 06b7c24 Compare December 11, 2019 07:44
PR rust-lang#66512 added the ability to set argv[0] on
Command. As a side effect, it changed the Debug output to print both the program and
argv[0], which in practice results in stuttery output ("echo echo foo").

This PR reverts the behaviour to the the old one, so that the command is only printed
once - unless arg0 has been set. In that case it emits "[command] arg0 arg1 ...".
@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 17, 2019

📌 Commit ce56e75 has been approved by joshtriplett

@bors
Copy link
Contributor

bors commented Dec 17, 2019

🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 17, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 20, 2019
…plett

Fix up Command Debug output when arg0 is specified.

PR rust-lang#66512 added the ability to set argv[0] on
Command. As a side effect, it changed the Debug output to print both the program and
argv[0], which in practice results in stuttery output (`"echo" "echo" "foo"`).

This PR reverts the behaviour to the the old one, so that the command is only printed
once - unless arg0 has been set. In that case it emits `"[command]" "arg0" "arg1" ...`.
Centril added a commit to Centril/rust that referenced this pull request Dec 20, 2019
…plett

Fix up Command Debug output when arg0 is specified.

PR rust-lang#66512 added the ability to set argv[0] on
Command. As a side effect, it changed the Debug output to print both the program and
argv[0], which in practice results in stuttery output (`"echo" "echo" "foo"`).

This PR reverts the behaviour to the the old one, so that the command is only printed
once - unless arg0 has been set. In that case it emits `"[command]" "arg0" "arg1" ...`.
bors added a commit that referenced this pull request Dec 20, 2019
Rollup of 7 pull requests

Successful merges:

 - #66755 (Remove a const-if-hack in RawVec)
 - #67127 (Use structured suggestion for disambiguating method calls)
 - #67219 (Fix up Command Debug output when arg0 is specified.)
 - #67285 (Indicate origin of where type parameter for uninferred types )
 - #67328 (Remove now-redundant range check on u128 -> f32 casts)
 - #67367 (Move command line option definitions into a dedicated file)
 - #67442 (Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.)

Failed merges:

r? @ghost
@bors bors merged commit ce56e75 into rust-lang:master Dec 20, 2019
@Mark-Simulacrum
Copy link
Member

I am nominating this for beta backport as it seems it's regressing some crates (i.e., this PR landed too late to fix beta as well). I tagged with T-compiler and T-libs; but I feel fairly confident that we just want to backport this. If T-compiler decides not to approve we'll want to ping T-libs as they don't generally notice otherwise I think.

@Mark-Simulacrum Mark-Simulacrum added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 25, 2019
@jsgf
Copy link
Contributor Author

jsgf commented Dec 26, 2019

@Mark-Simulacrum Do any of them seem to be using the Debug output for real functionality, or is it just unit tests failing?

@Mark-Simulacrum
Copy link
Member

AFAICT, just unit tests - though some are calling public functions, so a little unclear. The duplication of the executable though is somewhat annoying (and will affect other places, e.g. rustc output on failure to run linkers, I imagine).

@Mark-Simulacrum
Copy link
Member

@rust-lang/libs -- this is nominated for beta backport, and T-compiler (likely correctly :) decided that they feel that libs team should approve this. @pnkfelix will also write up a comment hopefully with some thoughts in an hour or so.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 2, 2020

Oh yeah, I promised a note here.

My instinct is that I wouldn't backport this PR, since it is inserting this new square-bracket delimted [command]. To me, a change like that seems like it would be better off riding the trains.

At the same time, there is a very real regression that should be addressed in some manner.

So what I would advise (and I'm speaking with basically zero authority here, since I'm not really involved with any libs design, apart from at best the Allocator API and the defunct placement-in APIs) is to backport a PR reverting all of #66512 from beta. But keep #66512 on nightly, and let this PR land there.


Before I started looking at this bug, I would have said that I believe our intent is that we are free to change std::fmt::Debug implementations for stdlib types at will. However, I am not sure if that policy is set in stone anywhere, so I am starting to doubt my own understanding of the guarantees here. The docs for the Debug trait and for std::fmt do not seem to make any strong statements giving stdlib the freedom that I thought it had to revise Debug implementations at will.


Update: Also, to be clear: as I understand it, this change really shouldn't be breaking anyone, at least no one who isn't already making use of the (brand-new) functionality to modify argv[0]. My arguments here are not really about stability guarantees. Rather, it is about giving people the chance, by riding the nightly trains, to discover problems with the choice to use square-brackets as the way to delimit the two distinct program name vs argv[0] values.)

@sfackler
Copy link
Member

sfackler commented Jan 2, 2020

Debug representations are subject to change at any time.

@Mark-Simulacrum
Copy link
Member

To be clear, I consider the behavior on beta at least suboptimal (double printing the program), and plausibly a bug. Given instability of Debug, though, we may decide to not actually backport anything and merely note it in the release notes.

@jsgf
Copy link
Contributor Author

jsgf commented Jan 2, 2020

The ["executable"] output will only appear if you're using the new API. With this change, the Debug output is unchanged for existing uses and hence avoid the double-printing. Without this change the Debug output changes for no reason and in a generally unhelpful way.

I see this as being a bugfix to the original PR and I think it would be best to backport it so that they both land together. Otherwise we'll end up with a release with a Debug output regression.

@alexcrichton
Copy link
Member

I personally think it's fine to backport this, so I'm going to accept it.

@alexcrichton alexcrichton added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jan 6, 2020
@jsgf
Copy link
Contributor Author

jsgf commented Jan 11, 2020

@alexcrichton What's the actual process for backporting? Should I submit a PR?

@Mark-Simulacrum
Copy link
Member

I will be doing a beta backport rollup today or tomorrow probably and this'll get picked up since it's been approved, so no need to do anything further.

bors added a commit that referenced this pull request Jan 14, 2020
[Beta] Backports

I did not include #67134 and #67289 since they seem to be on beta already.

* Fix up Command Debug output when arg0 is specified. #67219
* Do not ICE on unnamed future #67289
* Don't suppress move errors for union fields #67314
* Reenable static linking of libstdc++ on windows-gnu #67410
* Use the correct type for static qualifs #67621
* Treat extern statics just like statics in the "const pointer to static" representation #67630
* Do not ICE on lifetime error involving closures #67687
@jonas-schievink jonas-schievink removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants