Escaping a directory in a $PATH-like list

1

I'm developing a wrapper for LibGit2, the Git library.
And I come out with a problem:

Many GIT functions accept path lists, that is, a string
composed of a series of paths separated by a token,
that LibGit2 makes available to me. In my Linux, it is a colon (:).

The issue appears when I ask me:
what if the path contains this token?

Can it be escaped someway? \: or so?
Will it be supported out-of-the-box in Windows?

I know it's not common to have a directory containing : in his
name, but as a wrapper I have to be prepared for this case.

Alba Mendez

Posted 2013-01-26T10:06:51.997

Reputation: 143

Answers

1

I haven't checked libgit2, but neither git nor various $PATH users – such as the Glibc execvpe() function and various shells (dash, bash) – support any form of escaping – if a directory name contains a :, it simply cannot be used as part of path-related environment variables.

On Windows, the path separator is ; – you should be able to use PATH_SEP or a similar constant to find the value – and again, escaping is not supported anywhere.

If the user gives you a path like /usr/foo:bar, then they might be expecting it to be split into two directories, so just do that.

user1686

Posted 2013-01-26T10:06:51.997

Reputation: 283 655