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

Support escaping flags & options #452

Closed
ericcornelissen opened this issue Oct 5, 2022 · 1 comment · Fixed by #908
Closed

Support escaping flags & options #452

ericcornelissen opened this issue Oct 5, 2022 · 1 comment · Fixed by #908
Assignees
Labels
enhancement New feature or request

Comments

@ericcornelissen
Copy link
Owner

Feature Request

Description

Add support for escaping inputs that may be interpreted as flags/options (for Unix, arguments starting with - or -- appearing before an argument that is exactly --). This may be necessary as using a flag can change the behavior of a command unintentionally - for example, consider being able to add the --force flag to certain commands.

Proposal

To be decided (suggestions welcome)

@ericcornelissen
Copy link
Owner Author

Since flags/options are a convention rather than a shell requirement it will be hard to properly support this. On Unix systems flags/options nearly always start with - or --1 (I think this is a POSIX standard). On Windows systems / is used historically (from DOS), but many CLI tools accept - or -- nowadays. Thus, it seems the best approach is to "escape" leading - on Unix systems and leading / and - on Windows systems and allow users of Shescape to change the set of flag/option characters in case their tool does something else.

From my testing (and based on my understanding) "escaping" these characters (e.g. - as \- for Bash) won't work because the CLI program will receive the escaped characters (in this case just -). So, to "escape" flags/options, leading - (and / for Windows) will have to be removed entirely.

For the purposes of v1, this should be opt-in behavior since this really seems like a breaking change. In v2 the default behavior should be to "escape" flags/options, with an option to opt-out.

Footnotes

  1. Interestingly a string like ' --xyz' (flag with leading space that's preserved due to quoting) is rejected by all CLI tools I tested. But this is strictly an implementation detail, so even such strings should be "escaped".

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

Successfully merging a pull request may close this issue.

1 participant