What is the meaning of environment variable !::=::\

118 views Asked by At

I have found out my environment variables a strange line:

$ env
...
!::=::\
...

When I start a shell or run bash script, it is sometimes present, sometimes not. And when it is absent my bash calls to subshells $(...) require 3 escape backslashes instead of each 1.

Any idea what it is and how to set it?

1

There are 1 answers

1
Ross Ridge On BEST ANSWER

It's Cygwin's representation of one of the special environment variables created by the Windows command processor (cmd.exe) in order to track a separate current directory for each drive the same way MS-DOS did. You should also see entries like !C:=C:\Users\Ross Ridge in the output of env. The Windows command processor creates them in the form =X:=X:\Path, but Cygwin changes the initial = to a ! in order to make it a legal Unix environment entry.

So the reason why you see !::=::\ in the Cygwin environment is because =::=::\ was in the Windows environment that Cygwin inherited. I'm not sure why there was an =::=::\ entry in the Windows environment, : is not a legal drive letter, but Raymond Chen says it's a bug. It exists in the Windows environment on my computer even when I use Win-R to start Cygwin bash directly without using cmd.exe, so it's not clear what's actually setting it.