4

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?

Jahid
  • 21,542
  • 10
  • 90
  • 108
  • 1
    what OS and version? Also bash/zsh/etc? And version? AND do you work primarily inside of a Ruby or Python (or other) programming environment? Interesting. Good luck. – shellter Jun 09 '15 at 18:58
  • it's a bash only script, run under windows7 with cygwin. – Georgy Petrov Jun 09 '15 at 19:12
  • Maybe you could try grepping for that in your filesystem. Try some variations on `grep -r '!::=::\\' /`. Not sure how you'd need to change it up for cygwin, though. – Aereaux Jun 09 '15 at 19:31
  • 1
    At output of "env", what appears in line before and after this one? – pasaba por aqui Jun 09 '15 at 19:39
  • 1
    I see that env var in my git-bash environments also. Can you give an example of the sub-shell command issue? – Etan Reisner Jun 09 '15 at 20:49

1 Answers1

4

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.

Community
  • 1
  • 1
Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • Nicely found and good reference links. This doesn't answer the ancillary question about the escaping difference (but I'm skeptical about that issue to begin with). – Etan Reisner Jun 11 '15 at 13:27