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: unsolicited spreading/flattening of arguments #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kareem-Medhat
Copy link

@Kareem-Medhat Kareem-Medhat commented Aug 10, 2022

Program currently spreading/expanding quoted, multi-word arguments instead of forwarding them to script.

Changes

  • AppArgs now stores arguments in a Vec<String> rather than a String
  • Introduces new crate, shlex, to correctly parse arguments passed in interactive
    mode into a Vec<String>
  • Changes run_command function to correctly forward the arguments
  • If user passes invalid arguments in interactive mode ( such as leaving an open quote ) the user is warned and prompted again until the user passes valid arguments or exits

Behavior before changes

dum run foo "first arg" "second"
$ foo
$ node stuff/example-script first arg second
from example [ 'first', 'arg', 'second' ] # ❌ 3 arguments

Behavior after changes (desired behavior)

dum run foo "first arg" "second"
$ foo
$ node stuff/example-script "first arg" second
from example [ 'first arg', 'second' ] # ✅ 2 arguments

Fixes

fixes #59

Fixes bug by
- storing arguments in a `Vec<String>` rather than a `String`
- introducing new crate, `shlex`, to correctly parse arguments passed in interactive
  mode into a `Vec<String>`
- changing `run_command` function to correctly forward the arguments
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.

fix: spreading quoted, multi-word arguments instead of forwarding them to script
1 participant