Behaviour of Cygwin's `(no)dosfilewarning`

3

3

Original Question

Cygwin's CYGWIN environment variable and its contents have effect on several aspects of the Cygwin environment. If CYGWIN contains nodosfilewarning then

Cygwin will warn the first time a user uses an "MS-DOS" style path name rather than a POSIX-style path name

as stated by one of Cygwin FAQ pages.

What is first time? Once a day? Once between computer restarts?

I had set CYGWIN=nodosfilewarning, but still sometimes Cygwin warns me that I use MS-DOS style paths. If I set it to dosfilewarning (and restart my shell) I can't trigger the warning no matter what (like cd C:\\Windows—I assume this is MS-DOS-ish enough).

I don't exactly know if the CYGWIN variable have to be set at OS level or in my Cygwin shell, however I have tried both without success. By without success I mean, if the variable is set to dosfilewarning my assumption is that Cygwin should warn me every time I type something like cd C:\\Windows (which it doesn't do).

How can I verify that I set this stupid variable correctly and my settings are in effect? Cygwin's FAQ gives little help on this particular problem.

Update

Thanks to JdeBP's answer I've managed to come to the following conclusion.

The CYGWIN variable can be set either at OS level or in a Cygwin shell.

cd C:\\Windows doesn't trigger the warning at hand, but ls C:\\Windows does (talk about consistency, huh?).

For now, settings nodosfilewarning really reports no warning for the previously mentioned command, however I originally wrote this post because even though I told Cygwin not to report these warnings it still did sometimes. Unfortunately I don't know when and under what circumstances (I'll update the question if I further encounter these warnings).

Kohányi Róbert

Posted 2011-12-22T07:46:58.603

Reputation: 143

cd is not a program, but a command of the shell. Probably related to that. – Daniel Beck – 2011-12-24T07:26:13.693

@DanielBeck You're right, but I think one would still expect to trigger the warning nonetheless. – Kohányi Róbert – 2011-12-24T07:27:40.900

Answers

2

Every process that uses the Cygwin runtime library maps into that process a portion of shared memory. This contains some data that are shared across all processes using (that particular installation of) the Cygwin runtime library.

One of the flags in that shared memory is the warned_msdos flag. If the warned_msdos flag is false, and if dosfilewarning is set in the CYGWIN environment variable that the process had at process initialization, then you will see the warning. When the warning is issued, the warned_msdos flag is set to true.

Note, importantly:

  • The check won't be made in the first place by any process that had nodosfilewarning.
  • If the check isn't made, warned_msdos will remain set to false.
  • The shared memory stays around until all Cygwin processes using it terminate.

JdeBP

Posted 2011-12-22T07:46:58.603

Reputation: 23 855