zli5t / ShellQDB

A quote database implemented entirely in shell.
2 stars 0 forks source link

escq/unescq #1

Closed ethanjli closed 14 years ago

ethanjli commented 14 years ago

They aren't reversible in certain cases: The command echo " foo\nbar" | ./escq returns

foo\nbar , while the command echo " foo\nbar" | ./unescq returns foo bar . I'm not sure why this happens.
ethanjli commented 14 years ago

Also, the command echo " foo\bar" | ./unescq does NOT return

foo\\bar as it should.
zli5t commented 14 years ago

Remember to use single quotes! You're not sending what you think you're sending. Your second example is actually a non-problem, [skr@lambda qdc]$ echo " foo\nbar"

foo\nbar which is then parsed properly. However, [skr@lambda qdc]$ echo ' foo\nbar' foo\nbar ``` [skr@lambda qdc]$ echo ' foo\\nbar' | ./unescq foo\ bar ``` The latter is parsed as you say. I'll try to figure this out. Your comment is a non-issue; unescq actually works fine on that. Youre using double, not single quotes; furthermore, **escq** is supposed to do that, which it does admirably.
ethanjli commented 14 years ago

Remember to use single quotes! You're not sending what you think you're sending.

Okay. For future reference, what is the difference between single quotes and double quotes that causes this behavior?

furthermore, escq is supposed to do that.

Yeah, it was late at night

zli5t commented 14 years ago

Single quotes dont interpolate variables, dont care about backslashes: '$blah \' => $blah \ "$blah \" => [value of blah] \ '$blah \' lol ' => incorrectly parsed string. To insert a single quote into a single quote expression, leave the single quotes and use a backslash. '$blah '\'' lol' => $blah ' lol

Issue fixed; the newline thing needed a tiny careful tuneup. Check this thing out to see if i'm sane or not.

ethanjli commented 14 years ago

Yeah, it all makes sense now.