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

cross run interprets the program's arguments as its own (ignores --). #1048

Closed
4 of 11 tasks
zachs18 opened this issue Oct 3, 2022 · 0 comments · Fixed by #1049
Closed
4 of 11 tasks

cross run interprets the program's arguments as its own (ignores --). #1048

zachs18 opened this issue Oct 3, 2022 · 0 comments · Fixed by #1049

Comments

@zachs18
Copy link
Contributor

zachs18 commented Oct 3, 2022

Checklist

Describe your issue

(Not entirely sure if this should be an issue report or a feature request).

When a binary being run with cargo run takes arguments, you can tell cargo where its arguments end and where the program's arguments begin with --, e.g. cargo run --cargo-argument -- --program-argument.

cross does not currently do this, and it interprets --program-argument for itself, as well as passing it to the program. This was most noticeable for me with -v, since cross's verbose textual output to stdout interfered with a program's piped stdout.

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.4

Example

git clone https://github.com/zachs18/cross-rs-argument-example
bash test.sh

The repo contains a simple program:

fn main() {
    match std::env::args().nth(1) {
        None => println!("No arguments passed!"),
        Some(s) => if s == "-v" {
            println!("Verbose (-v) passed!");
        } else {
            println!("Something else ({s}) passed!");
        },
    };
}

The test.sh script calls cargo run and cross run --target=aarch64-unknown-linux-gnu (the specific target doesn't matter) with -- -v (and other argument configurations) to show the difference with cargo, e.g.

$ cargo run -- -v
// normal cargo output, followed by
Verbose (-v) passed!

$ cross run --target=aarch64-unknown-linux-gnu -- -v
// *verbose* cross output, followed by
Verbose (-v) passed!

$ cross run --target=aarch64-unknown-linux-gnu -v -- -v
// verbose cross output, followed by
Verbose (-v) passed!

expected:

$ cargo run -- -v
// normal cargo output, followed by
Verbose (-v) passed!

$ cross run --target=aarch64-unknown-linux-gnu -- -v
// *normal* cross output, followed by
Verbose (-v) passed!

$ cross run --target=aarch64-unknown-linux-gnu -v -- -v
// verbose cross output, followed by
Verbose (-v) passed!

Additional information / notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants