From: Junio C Hamano <hidden> Date: 2016-06-15 22:42:06
"H. Peter Anvin" [off-list ref] writes:
This patch adds an invocation of "env", so rsh.c works for C-shell users
as well as Bourne shell users.
Hmph. I think the original code is buggy already. If the path
has a single quote in it, you would get into a problem. If the
remote end first interprets what is given to it with C-shell,
then it probably would also barf if path had a '!' in it, too,
even though we quote the entire thing within a single-quote
pair.
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:06
Junio C Hamano wrote:
"H. Peter Anvin" [off-list ref] writes:
quoted
This patch adds an invocation of "env", so rsh.c works for C-shell users
as well as Bourne shell users.
Hmph. I think the original code is buggy already. If the path
has a single quote in it, you would get into a problem. If the
remote end first interprets what is given to it with C-shell,
then it probably would also barf if path had a '!' in it, too,
even though we quote the entire thing within a single-quote
pair.
True. The better method is to \-escape any questionable characters,
instead of trying to use quotes. I'll try to write that up.
-hpa
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:06
Okay, I'm trying to put together some rules that should work across shells.
For byte values:
0 Hopeless - not representable in C strings
1-31,127 Prefix with ^V if (and only if!) entered at a prompt,
as opposed to passed in the ssh command field
32-126 \-escape all characters except -+_@=:.,/ and
ASCII alphanumerics
128- Don't escape (would have to be done differently
depending on locale, and shouldn't be needed)
Anyone know of a system for which that breaks horribly? The 1-31,127
stuff is iffy, but I just don't know of anything that's more reliable.
Unfortunately \010-style quoting doesn't work in any of the common shells.
-hpa
Okay, I'm trying to put together some rules that should work across shells.
Does anybody really still use tcsh? It's a broken mess.
Junio's "sq_quote()" works wonderfully on any valid shells. The fact that
tcsh expands ! even inside single quotes is just pure braindamage.
You could expand "sq_quote" to handle '!' and '\' characters the exact
same way it handles the single tick (end single-tick quoting, do \! or \\
and start single-tick quoting again) and that might be good enough for
tcsh.
IOW, the string "a\b'c!d" would become 'a'\\'b'\''c'\!'d' after
surrounding sq_quote with single-ticks.
Insane?
Linus
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:06
Linus Torvalds wrote:
Does anybody really still use tcsh? It's a broken mess.
Yes.
Junio's "sq_quote()" works wonderfully on any valid shells. The fact that
tcsh expands ! even inside single quotes is just pure braindamage.
You could expand "sq_quote" to handle '!' and '\' characters the exact
same way it handles the single tick (end single-tick quoting, do \! or \\
and start single-tick quoting again) and that might be good enough for
tcsh.
It seems easier to just \-escape any special characters.
-hpa
From: "H. Peter Anvin" <hpa@zytor.com> Date: 2016-06-15 22:42:06
This patch does proper quoting, and uses "env" to be compatible with
tcsh. As a side benefit, I believe the code is a lot cleaner to read.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>