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

Use OS-native argument handling #1

Closed
wants to merge 1 commit into from

Conversation

HeroicKatora
Copy link

This fixes edge cases where the output file might have a non-UTF8
filename, this would panic when using env::args. It also uses the
standard file_name method instead of an ad-hoc parsers for retrieving
the program's command name in its help.

This fixes edge cases where the output file might have a non-UTF8
filename, this would panic when using `env::args`. It also uses the
standard file_name method instead of an ad-hoc parsers for retrieving
the program's command name in its help.
@HeroicKatora
Copy link
Author

HeroicKatora commented Mar 2, 2021

This doesn't actually fix everything. What I was hoping to achieve was to handle arguments such as:

#!/bin/bash
echo hello > $'./\xff' # Okay, a valid file under Linux/ext4
echo hello | rewrite $'./\xff' # Currently:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "\xFF"', library/std/src/env.rs:772:51
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Instead, it now fails in getopts, more specifically here where it will try to match the argument and results in returning an error:

Unrecognized option: '"./\xFF"'
Usage: rewrite FILE [options]

Options:
    -h, --help          prints this help info

@mqudsi
Copy link
Member

mqudsi commented Mar 2, 2021

Hello @HeroicKatora and thanks for the PR. I'll take a look and see why getopts doesn't like this.

@HeroicKatora
Copy link
Author

I found a tracking issue: rust-lang/getopts#97

1 similar comment
@HeroicKatora

This comment has been minimized.

@mqudsi mqudsi closed this in c1f0ec2 Mar 2, 2021
mqudsi added a commit that referenced this pull request Mar 2, 2021
It's crusty and old, and was causing problems preventing non-Unicode
paths from being used as destinations.

See rust-lang/getopts#97

Closes #1.
@mqudsi
Copy link
Member

mqudsi commented Mar 2, 2021

@HeroicKatora can you please try building from master with 2367be0?

@HeroicKatora
Copy link
Author

Works like a charm 👍

@mqudsi
Copy link
Member

mqudsi commented Mar 2, 2021

Awesome, thanks for confirming!

@HeroicKatora HeroicKatora deleted the os-args branch March 2, 2021 19:24
@HeroicKatora
Copy link
Author

Could you do a cargo release for this feature? Maybe consider even 1.0 as the interface itself looks quite stable now, unless you have some concrete plans for changing it soon.

@mqudsi
Copy link
Member

mqudsi commented Mar 3, 2021

Done! You've been named in the release notes.

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

Successfully merging this pull request may close these issues.

None yet

2 participants