question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Argument Parsing with spaces?

See original GitHub issue

I’m not sure if is an edge case that yargs should address.

When a program is executed from a script like bash -e /script_run_yargs_program.sh ie GitHub actions run: if there are any trailing spaces after a slash on a multi-line script they get interrupted as an argument and you get a very unhelpful error message

Unknown argument:  

being akin to printf("Unknown argument: %s" , " ")

see: https://github.com/iterative/cml/issues/727#issuecomment-924443434 for an example

I realize this could be an unsupported edge case and Ideally people aren’t putting trailing spaces after their 's 😉

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bcoecommented, Sep 23, 2021

@DanielBarnes, I like @0x2b3bfa0’s suggestion… I don’t thin kit would be ridiculous to trim the strings we parse too, I’d have to look at the parser to see how painful this is.

2reactions
0x2b3bfa0commented, Sep 22, 2021

It would be nice to quote unknown options so users can notice whitespace:

Unknown argument: ' '
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle spaces in argparse input - python - Stack Overflow
Simple solution: argparse considers a space filled string as a single argument if it is encapsulated by quotation marks.
Read more >
Parsing C command-line arguments - Microsoft Learn
Arguments are delimited by whitespace characters, which are either spaces or tabs. The first argument ( argv[0] ) is treated specially. It ...
Read more >
Python Script Execution error while passing the string with space
If you want to pass named string arguments containing spaces in between to the python script, you can simply put the text in...
Read more >
How to parse arguments with space inside bash function
Sounds like you want to split the first argument your function receives on space characters. For that, you could use the split+glob operator ......
Read more >
Passing arguments with spaces? · Issue #39 · trevorld/r-optparse
Hi, is there any way to pass arguments with spaces? I currently need to pass a filename and it keeps splitting it into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found