kristopolous / TickTick

JSON in your Bash scripts

Home Page:http://9ol.es/TheEmperorsNewClothes.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quoted arguments get broken up

runvnc opened this issue · comments

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.

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?

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.

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?