For bash the path separator for the environment variable $PATH is ":"
So out of curiosity:
if a have a directory named
$HOME/with:character
Is there any way I can add it to the search path?
Please note that I think adding : to a filename is not a very smart idea, but I wanted to know if I could add such a directory to a search path if I ever encountered one
I tried with a backslash, but this doesn't seem to work:
export PATH="$PATH:$HOME/with\\:character"
double : (::) doesn't work either
:is not even allowed in a file / directory name. I personally stick to lowercase letters, numbers and underscores whenever possible – gelonida Mar 19 '21 at 11:08/but:can be misinterpreted as a path separator too, so really should be avoided. – Tetsujin Mar 19 '21 at 11:10:character to a search path.Is there any kind of escaping?
Again I would never use this in real life. but I'm curious
– gelonida Mar 19 '21 at 11:13~is expanded prior to assigning the value toPATHSo PATH contains
/home/gelonida/with\\:characterIf I wanted a
– gelonida Mar 19 '21 at 11:27~I had to typeexport PATH=$PATH:\~/with\\:character(I'm using bash)export).shon the other hand may not. – Kamil Maciorowski Mar 19 '21 at 11:33~– gelonida Mar 19 '21 at 11:40~from my question. Though the question was tagged asbash, it might also be read by others. This is probably a good idea as it is not relevant for the rest of the question – gelonida Mar 19 '21 at 11:42~in languages likepythonThis will fail except they use something likeos.path.expanduser("~/with:character")– gelonida Mar 19 '21 at 11:46