Loading ...
Sorry, an error occurred while loading the content.

vim treats "write only" files as "read only"

Expand Messages
  • Rahul
    Purely for kicks I tried editing a file with vim that was write only . i.e. with mask as -w- vim warns me that this is a read only file and cannot be
    Message 1 of 5 , Apr 24, 2009
    • 0 Attachment
      Purely for kicks I tried editing a file with vim that was "write
      only". i.e. with mask as -w-

      vim warns me that this is a "read only" file and cannot be edited.

      Just curious if this is a side effect or has other implications. Why
      does vim treat "write only" files as "read only"?

      Incidentally I don't have any use for a "write only" file. It is just
      my curiosity that is trying to figure out if there was a use.

      --
      Rahul

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ben Schmidt
      ... Really? My vim does what I would expect it to do: gives a Permission denied error (well, just a message, actually, I think). ... It sets the readonly
      Message 2 of 5 , Apr 26, 2009
      • 0 Attachment
        > Purely for kicks I tried editing a file with vim that was "write
        > only". i.e. with mask as -w-
        >
        > vim warns me that this is a "read only" file and cannot be edited.

        Really? My vim does what I would expect it to do: gives a 'Permission
        denied' error (well, just a message, actually, I think).

        > Just curious if this is a side effect or has other implications. Why
        > does vim treat "write only" files as "read only"?

        It sets the 'readonly' option of the buffer to prevent you from too
        easily accidentally overwriting the file. It really just means it forces
        you to use a bang (!) when writing the file.

        > Incidentally I don't have any use for a "write only" file. It is just
        > my curiosity that is trying to figure out if there was a use.

        There are uses, but they are rare, and, to be honest, I think other
        mechanisms are pretty universally preferred now. The most obvious one is
        log files (or mailboxes):

        cat Here is a new message >> log-file
        cat Here is a new message >> mailbox-belonging-to-somebody-else

        You can add messages, but you can't see anybody else's messages.

        Of course, to avoid having messages from multiple users clobbered or
        mixed up by two people writing at the same time, some locking mechanism
        needs to be used in this application.

        Ben.




        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Jason Axelson
        On Sun, Apr 26, 2009 at 2:38 PM, Ben Schmidt ... Shouldn t that be echo instead of cat? Jason --~--~---------~--~----~------------~-------~--~----~ You
        Message 3 of 5 , Apr 26, 2009
        • 0 Attachment
          On Sun, Apr 26, 2009 at 2:38 PM, Ben Schmidt
          <mail_ben_schmidt@...> wrote:
          > cat Here is a new message >> log-file
          > cat Here is a new message >> mailbox-belonging-to-somebody-else

          Shouldn't that be echo instead of cat?

          Jason

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • pansz
          ... In my vim, it gives the permission denied for -w------- (200) file. Write-only files has uses for IO devices/CPU ports. write to those files will trigger
          Message 4 of 5 , Apr 26, 2009
          • 0 Attachment
            Rahul 写道:
            > Purely for kicks I tried editing a file with vim that was "write
            > only". i.e. with mask as -w-
            >
            > vim warns me that this is a "read only" file and cannot be edited.
            >
            > Just curious if this is a side effect or has other implications. Why
            > does vim treat "write only" files as "read only"?

            In my vim, it gives the "permission denied" for -w------- (200) file.

            Write-only files has uses for IO devices/CPU ports. write to those files
            will trigger event and do some hardware operation, while read to those
            files may be prohibited.



            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Tony Mechelynck
            ... Hm, yes; or else, cat message.eml /var/mail/root sending an internal email from any user to the sysadmin; though a mail-server daemon might be
            Message 5 of 5 , May 1, 2009
            • 0 Attachment
              On 27/04/09 02:50, Jason Axelson wrote:
              >
              > On Sun, Apr 26, 2009 at 2:38 PM, Ben Schmidt
              > <mail_ben_schmidt@...> wrote:
              >> cat Here is a new message>> log-file
              >> cat Here is a new message>> mailbox-belonging-to-somebody-else
              >
              > Shouldn't that be echo instead of cat?
              >
              > Jason

              Hm, yes; or else,

              cat message.eml >> /var/mail/root

              sending an "internal email" from any user to the sysadmin; though a
              mail-server daemon might be cleaner.


              Best regards,
              Tony.
              --
              "The chain which can be yanked is not the eternal chain."
              -- G. Fitch

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.