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

Quoted arguments get broken up #32

Open
runvnc opened this issue May 19, 2014 · 3 comments · May be fixed by #52
Open

Quoted arguments get broken up #32

runvnc opened this issue May 19, 2014 · 3 comments · May be fixed by #52

Comments

@runvnc
Copy link

runvnc commented May 19, 2014

TickTick provides, in my opinion, an API that is obviously much nicer than the other bash JSON parsers. So I was using it in my script.

Unfortunately, I had to switch to JSON.sh because I could not figure out (at least not in the hour or so I spent diagnosing and trying to fix this issue, I am not a bash expert) how to fix this problem: when passing arguments that are quoted for example myscript last Smith first John address "123 Main St." after the . ./ticktick.sh the last arguments change as if they were not quoted e.g. myscript last Smith first Smith address 123 Main St.. I am using shift in part of my script to read key/value pairs from the arguments and I was getting Main assigned as a key rather than part of the address value.

@runvnc runvnc closed this as completed May 19, 2014
@runvnc runvnc reopened this May 19, 2014
@kristopolous
Copy link
Owner

This sounds like a common mistake. I don't know where it is or how to fix it for your case.

Can I get the script in question here?

@kristopolous
Copy link
Owner

Sorry I should make it clear that I'm not claiming it's your mistake... It's just common for quotes to be dropped at times.

But I can't identify the place this is happening (in my library or wherever) until I see the context.

@Artoria2e5
Copy link

This is because the ARGV=$@ handling loses the word boundary. To fix it you gotta do ARGV=("$@"), and expand it using "${ARGV[@]}" later.

I see you already have a bash-array branch for this sort of stuff. Why not try resurrecting it?

Artoria2e5 added a commit to Artoria2e5/TickTick that referenced this issue May 28, 2020
* ARGV is now an array. Should fix kristopolous#32.
* Quotes and stuff, also in generated code.
* Not using `...` is a good idea because it effs up badly when you nest them. It's also in shellcheck.
* Catch bad args in tickVars.

* * *

POSIX interaction, in case people want it later:
* No arrays, but we aren't gonna do the transpiling anyways.
* No +=, so it's gonna be dreadfully slow for long args. Remember the quadratic string append stuff in JS? Yeah it's exactly that.
* No ${var/pat/sub}, so dreadfully slow again. Prefix and suffix trimming is available though.
* No (( ... )), but `: $(( ))` is the same. Except for `++`.
@Artoria2e5 Artoria2e5 linked a pull request May 28, 2020 that will close this issue
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 a pull request may close this issue.

4 participants
@kristopolous @runvnc @Artoria2e5 and others