RFC: Transparent subrepository support by match module

Daniel J. Lauk daniel.lauk at gmail.com
Wed Aug 11 15:48:50 CDT 2010


Hello Klaus

I don't think that your idea with \0 would work.

You must distinguish between \0 as a representation for the (binary)
NUL character and the string "backslash zero".
As far as I know, you cannot provide the NUL character in a string on
a bash command line.

> Ahem, the '\0' *can* be used as long as it is quoted, can't it?

Well, yes, you can write a command like echo '\0', but it means "print
out a string made up of backslash and zero" (and not the NUL
character).

>> python -c 'import sys; print sys.argv[-1]' '\0'
> \0

While that is correct, it's a misperception. Don't let the output fool
you. Have a look at this:

$ python -c 'import sys; print "string value:", sys.argv[-1]; print
"internal representation:", repr(sys.argv[-1])' '\0'
string value: \0
internal representation: '\\0'

(Note the quotes and escaped backslash.)

> but
>
>> touch '\0'
> produces a file with name '\\0'

Again, the problem is, that bash would not escape the backslash when
you list the directory:

$ touch '\0'
$ ls -rt|tail -n 1
\0

The same things will happen with other special characters and ther
string representations, e.g. newline:

$ touch '\n'
$ ls -rt|tail -n 1
\n
$ python -c 'import sys; print "string value:", sys.argv[-1]; print
"internal representation:", repr(sys.argv[-1])' '\n'
string value: \n
internal representation: '\\n'

I hope that helped you out.

Cheers,
DJ

PS: Note that all I wrote is with regard to bash. I'm not really
experienced with other shells.


More information about the Mercurial-devel mailing list