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

ignore extra macos parameter #1608

Open
sixcorners opened this issue Dec 18, 2019 · 3 comments
Open

ignore extra macos parameter #1608

sixcorners opened this issue Dec 18, 2019 · 3 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-enhancement Category: Raise on the bar on expectations S-waiting-on-decision Status: Waiting on a go/no-go before implementing

Comments

@sixcorners
Copy link

When you start an app on macos it will sometimes pass a process serial number. This blows up apps that use clap.
The place where it is getting passed for me is from the "App downloaded from the internet" dialog box. When you click open it will try to open the rust app but fail and do nothing. If you ignored a parameter that looks like this -psn_0_5539144 on macos then this would be fixed for all apps using clap.

Rust Version

rustc 1.39.0

Affected Version of clap

whatever the latest is (v2.31.2)

Expected Behavior Summary

App doesn't fail when running from the "App downloaded from the internet" dialog box.

Actual Behavior Summary

"error: Found argument '-p' which wasn't expected, or isn't valid in this context"

Steps to Reproduce the issue

Launch a rust application on macos from the "App downloaded from the internet" warning dialog box.

@sixcorners sixcorners changed the title Handle macos process serial number ignore extra macos parameter Dec 19, 2019
@nixpulvis
Copy link

nixpulvis commented Jan 3, 2020

IMO, this is a tragic interface being forced upon the community by Apple. Why should argument parsers need to deal with this, or applications without a need for the PSN. Couldn't it be passed in the ENV much more transparently?

Either way it seems many applications don't care about this PSN, for example:

https://github.com/bitcoin/bitcoin/blob/b6e34afe9735faf97d6be7a90fafd33ec18c0cbb/src/util/system.cpp#L383-L389

So adding an option to ignore it on macOS may make sense. I wouldn't want non-macOS code to need to care though.

@chrisduerr
Copy link

If this was ignored in clap directly, I also think that it probably shouldn't just be done automatically without any compile-time checks. If a user wants to add their own -psn flag, things shouldn't explode.

Though I don't think it's possible to build the string -psn_ as option right now, so that should be fine. But blocking just -psn would certainly cause huge troubles.

@CreepySkeleton CreepySkeleton added P4: nice to have S-waiting-on-decision Status: Waiting on a go/no-go before implementing and removed W: after v3 release labels Feb 1, 2020
@pksunkara pksunkara removed the W: 2.x label Oct 26, 2020
@woelper
Copy link

woelper commented Mar 4, 2021

I had this issue, too - in case it helps anyone, i used .get_matches_from() and filtered incoming arguments before with let args: Vec<String> = std::env::args().filter(|a| !a.contains("psn_")).collect();

@pksunkara pksunkara removed the W: 3.x label Aug 13, 2021
@epage epage added A-parsing Area: Parser's logic and needs it changed somehow. C-enhancement Category: Raise on the bar on expectations and removed C: args labels Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-enhancement Category: Raise on the bar on expectations S-waiting-on-decision Status: Waiting on a go/no-go before implementing
Projects
None yet
Development

No branches or pull requests

7 participants