James F. Carroll wrote:
> Adam, you're amazing!  Thanks!
>
> So... what file am I editing?  vim says:
>
>  "/dev/fd/63" [fifo/socket] 72L, 3892C
>
> As the filename in the bottom left.  And I'm not allowed to write to
> it.  When I try to write the file (:w), I get:

The bash <(...) and >(...) constructs each create a temporary named
pipe, which is a FIFO.  It lives on the filesystem, but it's not
strictly speaking a file; it's a special type of node.

Bash hooks the output of the command to the FIFO (or input, in the case
of >(...)) and passes the name of the file to the main command-line so
it can open it for input (or output, as the case may be).  This name is
the one you're seeing in the status line.

Once Vim launches, it reads the contents of the FIFO (which causes the
command to be run, producing Vim's input) and stores it in a buffer you
can edit.  Since the original file is actually a FIFO and you're on the
reading end, the OS won't allow you to save to it, so if you want to
save the buffer, you have to pick another filename.  (The Vim command is
:sav foo.txt, in case you didn't know it.)

Once you quit vim, bash removes the FIFO and the whole world is a
cleaner place :D.

Incidentally, it's kind of the same story when you use "env | vim -",
except in this case, the dash tells vim to read its standard input for
the buffer contents.  This is also a pipe, but it's just the standard
input pipe that every application gets.  In this case, the dash is a
signal to Vim and there is logic within Vim to interpret it.  By
contrast, with the named pipe, Vim sees a regular old file name on its
command line (representing the FIFO) and just reads from it like a
normal file (although I'm sure Vim's smart enough to recognize that it's
a special file type and treat it slightly different for saving, etc.).
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to