Re: where was mention of what creates NUL files?

2013-06-27 Thread g



Daniel Barclay daniel at fgm.com writes:

 
 Does anyone recall a mention of what in CygWin (or possibly Emacs) creates
 files with a simple name of NUL?
 
 Thanks,
 Daniel
 
 


This has been driving me nuts for years. Finally tracked it down.
These are created by emacs' man.el code when you get a man page.
Reproduce: 
In emacs, do:
M-x man ret
enter anything, valid ('ls') or not
Now, you'll see a NUL file in the directory.

Root cause:
construction of the 'man' command that is passed to the shell includes:
(concat  %s 2 null-device)

The variable `null-device' is platform specific and defaults to a pure-copy
of /dev/null which, apparently, becomes NUL on windows.

It is a defvar in files.el and 'set' again in dos-w32.el.

Resolution:
In your .emacs file, do:

   (require 'dos-w32) ;; load this first to avoid it undo'ing the next line
   (setq null-device c:/tmp/emacs-dev-null.txt) ;; set to anything

Happy days!




--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2013-06-27 Thread Ken Brown

On 6/26/2013 2:53 PM, g wrote:




Daniel Barclay daniel at fgm.com writes:



Does anyone recall a mention of what in CygWin (or possibly Emacs) creates
files with a simple name of NUL?

Thanks,
Daniel





This has been driving me nuts for years. Finally tracked it down.
These are created by emacs' man.el code when you get a man page.
Reproduce:
In emacs, do:
 M-x man ret
 enter anything, valid ('ls') or not
Now, you'll see a NUL file in the directory.


I can't reproduce this with Cygwin emacs.  You must be using native 
Windows emacs.



Root cause:
construction of the 'man' command that is passed to the shell includes:
(concat  %s 2 null-device)

The variable `null-device' is platform specific and defaults to a pure-copy
of /dev/null which, apparently, becomes NUL on windows.

It is a defvar in files.el and 'set' again in dos-w32.el.

Resolution:
In your .emacs file, do:

(require 'dos-w32) ;; load this first to avoid it undo'ing the next line
(setq null-device c:/tmp/emacs-dev-null.txt) ;; set to anything


Just to be clear, users of Cygwin emacs should *not* do this.

Ken

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2013-06-27 Thread wynfield

I do not have the problem using emacs built on cygwin either.


 On 6/26/2013 2:53 PM, g wrote:
 
 
 
  Daniel Barclay daniel at fgm.com writes:
 
 
  Does anyone recall a mention of what in CygWin (or possibly Emacs) creates
  files with a simple name of NUL?
 
  Thanks,
  Daniel
 
 
 
 
  This has been driving me nuts for years. Finally tracked it down.
  These are created by emacs' man.el code when you get a man page.
  Reproduce:
  In emacs, do:
   M-x man ret
   enter anything, valid ('ls') or not
  Now, you'll see a NUL file in the directory.
 
 I can't reproduce this with Cygwin emacs.  You must be using native
 Windows emacs.
 
  Root cause:
  construction of the 'man' command that is passed to the shell includes:
  (concat  %s 2 null-device)
 
  The variable `null-device' is platform specific and defaults to a pure-copy
  of /dev/null which, apparently, becomes NUL on windows.
 
  It is a defvar in files.el and 'set' again in dos-w32.el.
 
  Resolution:
  In your .emacs file, do:
 
  (require 'dos-w32) ;; load this first to avoid it undo'ing the next line
  (setq null-device c:/tmp/emacs-dev-null.txt) ;; set to anything
 
 Just to be clear, users of Cygwin emacs should *not* do this.
 
 Ken
 
 

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2010-09-20 Thread Oleksandr Gavenko

On 17.09.2010 20:12, Daniel Barclay wrote:

Does anyone recall a mention of what in CygWin (or possibly Emacs) creates
files with a simple name of NUL?


I also use native Emacs and after some operation I got file with name NUL.

I have a lot NUL files in many dirs, which can be removed only from Cygwin:

  $ rm NUL

I don't fully  debug but think this come from 'null-device' variable
(which has 'NUL' value by default).

To friend native GNU Emacs with Cygwin (and stop creating NUL) I use:

(when (eq system-type 'windows-nt)
  (setq shell-file-name bash)
  ;; Workaround for Cygwin shell, when set 'CYGWIN=noglob'. By default 
'shell-quote-argument'

  ;; quoted by double '\' chars this cause failure.
  (defun shell-quote-argument (argument)
(concat ' argument ')
)
  ;; Workaround for Cygwin when 'shell-file-name' is 'bash'.
  (setq null-device /dev/null)
  )

--
Happy hacking!


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2010-09-17 Thread Eric Blake

On 09/17/2010 11:12 AM, Daniel Barclay wrote:

Does anyone recall a mention of what in CygWin (or possibly Emacs) creates
files with a simple name of NUL?


Windows automagically maps the file named NUL, in any directory, to 
the equivalent of Unix' /dev/null.  Cygwin doesn't create it, but all 
the same, portable programs should never name a file that 
case-insensitively matches 'nul', 'aux', or a host of other 
windows-magic names:


http://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions

Meanwhile, cygwin 1.7 has added some magic to use native NT calls to 
work around these limitations, so that you can have a file that appears 
to be named NUL from within cygwin, but which is really exploiting 
some 16-bit values outside of Unicode.  But various windows programs 
that use windows API (rather than lower-level NT API), including your 
file Explorer, have a hard time figuring out what cygwin did.


--
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2010-09-17 Thread Corinna Vinschen
On Sep 17 11:22, Eric Blake wrote:
 On 09/17/2010 11:12 AM, Daniel Barclay wrote:
 Does anyone recall a mention of what in CygWin (or possibly Emacs) creates

finicking
It's Cygwin, not CygWin.
/finicking

files with a simple name of NUL?
 
 Windows automagically maps the file named NUL, in any directory,

Meep!  The Win32 API, not Windows per se.

 to the equivalent of Unix' /dev/null.  Cygwin doesn't create it, but
 all the same, portable programs should never name a file that
 case-insensitively matches 'nul', 'aux', or a host of other
 windows-magic names:
 
 http://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions
 
 Meanwhile, cygwin 1.7 has added some magic to use native NT calls to
 work around these limitations, so that you can have a file that
 appears to be named NUL from within cygwin, but which is really
 exploiting some 16-bit values outside of Unicode.

Sorry, but that's not entirely correct.  There isn't any magic involved
and the resulting filename is actually nul.  No mapping to the Unicode
private use area.

The terrible DOS device name hack, which maps filenames containing
substring named like the the old DOS device names (NUL, AUX, PRN, etc)
to the actual Windows device, only exists in the Win32 API.  Cygwin
doesn't use the Win32 API to access files, rather it uses the underlying
native NT API.  This API allows to create and access actual files like
nul or aux.c, just as on any other OS.  The DOS device name hack
simply doesn't affect us.

So, any Cygwin application can create files like nul.  It happens, for
instance, if you call something like:

  $ echo foo  NUL
  $ ls -l NUL
  -rw-r--r-- 1 corinna vinschen 4 Sep 17 21:25 NUL

Note:  Don't use DOS device names in Cygwin!

  Wrong:

$ echo foo  NUL
$ echo foo  nul
$ echo foo  nul:

  Right:

$ echo foo  /dev/null

See here:
http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-dosdevices
and here:
http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-posixdevices


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: where was mention of what creates NUL files?

2010-09-17 Thread Daniel Barclay

Corinna Vinschen wrote:
...


Note:  Don't use DOS device names in Cygwin!

   Wrong:

 $ echo foo  NUL
 $ echo foo  nul
 $ echo foo  nul:

   Right:

 $ echo foo  /dev/null


Yes, I know.  I'm not using NUL (or nul or nul:, etc.), but something
is.

(Now I'm thinking that it's an NTEmacs problem (perhaps thinking it's
running commands in a Windows/DOS shell rather than knowing it's
running them in Cygwin bash.).)



Daniel



--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple