Re: User-relative paths

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: User-relative paths

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:09

Linus Torvalds [off-list ref] writes:
It's incomplete and almost certainly buggy and generally broken, but 
here's somethign that you _could_ install as "git-shell", and then put 
that as somebodys shell in /etc/passwd, and it's a start. A very rough 
start.

Somebody else gets to test it out ;)

+		if (c != '\'') {
+			*dst++ = c;
+			continue;
+		}
+		switch (*++src) {
+		case '\0':
+			*dst = 0;
+			return arg;
+		case '\\':
+			if (*++src == '\'' &&
+			    *++src == '\'') {
+				*dst = '\'';
+				continue;
+			}
+		/* Fallthrough */
+		default:
I think this misses HPA's addition to minimally suppport csh
braindamage (bang bang).

Re: User-relative paths

From: "H. Peter Anvin" <hpa@zytor.com>
Date: 2016-06-15 22:42:09

Junio C Hamano wrote:
Linus Torvalds [off-list ref] writes:

quoted
It's incomplete and almost certainly buggy and generally broken, but 
here's somethign that you _could_ install as "git-shell", and then put 
that as somebodys shell in /etc/passwd, and it's a start. A very rough 
start.

Somebody else gets to test it out ;)

+		if (c != '\'') {
+			*dst++ = c;
+			continue;
+		}
+		switch (*++src) {
+		case '\0':
+			*dst = 0;
+			return arg;
+		case '\\':
+			if (*++src == '\'' &&
+			    *++src == '\'') {
+				*dst = '\'';
+				continue;
+			}
+		/* Fallthrough */
+		default:
I think this misses HPA's addition to minimally suppport csh
braindamage (bang bang).
If this is meant to dequote shell-quoted paths, it really should be modal.

	-hpa

Re: User-relative paths

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:09


On Sun, 23 Oct 2005, H. Peter Anvin wrote:
If this is meant to dequote shell-quoted paths, it really should be modal.
It _only_ accepts quoted strings, so it "is" modal. It has one mode: 
string. And it's a bitch about enforcing it, too (it just dies if it 
wasn't one).

		Linus

Re: User-relative paths

From: "H. Peter Anvin" <hpa@zytor.com>
Date: 2016-06-15 22:42:09

Linus Torvalds wrote:
On Sun, 23 Oct 2005, H. Peter Anvin wrote:
quoted
If this is meant to dequote shell-quoted paths, it really should be modal.
It _only_ accepts quoted strings, so it "is" modal. It has one mode: 
string. And it's a bitch about enforcing it, too (it just dies if it 
wasn't one).
That wasn't what I meant.  '...' is a modal escape in the shell.  Thus, 
something like this which actually mimics the state machine, at least 
for the potential characters we care about.


#define EMIT(x) { ( ++len < n ) && *dst++ = (x) )

int unquote(char *dst, size_t n, const char *src)
{
	enum state st = { st_zero, st_quote, st_escape };
	int len = 0;
	char c;
	
	while ( (c = *src++) ) {
		switch ( st ) {
		case st_zero:
			if ( c == '\'' )
				st = st_quote;
			else if ( c == '\\' )
				st = st_escape;
			else
				EMIT(c);
			break;
			
		case st_quote:
			if ( c == '\'' )
				st = st_zero;
			else
				EMIT(c);
			break;
			
		case st_escape:
			EMIT(c);
			st = st_zero;
			break;
		}
	}
	
	if ( n )
		*dst = 0;
	
	return (st == st_zero) ? len : -1;
}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help