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

exit value of vim ?

Expand Messages
  • Johannes Zellner
    I just tried to `crontab -e but crontab says `no changes made to crontab and ignores the result. I retried with EDITOR=levee and it worked. I don t know how
    Message 1 of 9 , Oct 16, 2000
    • 0 Attachment
      I just tried to `crontab -e' but crontab says
      `no changes made to crontab' and ignores the
      result. I retried with EDITOR=levee and it worked.
      I don't know how crontab determines if a file
      was modified but maybe it checks the exit
      status of the EDITOR?

      --
      Johannes
    • raf
      ... no, it compares the text of the temporary file that it gives you (e.g. /tmp/crontabXYZ) to edit with the existing crontab file. maybe you changed the name
      Message 2 of 9 , Oct 17, 2000
      • 0 Attachment
        Johannes Zellner wrote:

        > I just tried to `crontab -e' but crontab says
        > `no changes made to crontab' and ignores the
        > result. I retried with EDITOR=levee and it worked.
        > I don't know how crontab determines if a file
        > was modified but maybe it checks the exit
        > status of the EDITOR?

        no, it compares the text of the temporary file that it gives
        you (e.g. /tmp/crontabXYZ) to edit with the existing crontab
        file. maybe you changed the name of the file being edited before
        making changes? (e.g. :f, :e).

        raf
      • Johannes Zellner
        ... no. This can t be. I did a `crontab -e , edited, did :w , checked the changes by going to another window (while the editor was still open) and doing `cat
        Message 3 of 9 , Oct 17, 2000
        • 0 Attachment
          On Tue, Oct 17, 2000 at 06:09:55PM +1100, raf wrote:
          > Johannes Zellner wrote:
          >
          > > I just tried to `crontab -e' but crontab says
          > > `no changes made to crontab' and ignores the
          > > result. I retried with EDITOR=levee and it worked.
          > > I don't know how crontab determines if a file
          > > was modified but maybe it checks the exit
          > > status of the EDITOR?
          >
          > no, it compares the text of the temporary file that it gives
          > you (e.g. /tmp/crontabXYZ) to edit with the existing crontab
          > file. maybe you changed the name of the file being edited before
          > making changes? (e.g. :f, :e).

          no. This can't be. I did a `crontab -e', edited, did ':w',
          checked the changes by going to another window (while the
          editor was still open) and doing `cat /tmp/crontab.XXXXIrzLfZ'
          and yes: the changes were there. Going back to vim and doing
          `:q' and getting still `no changes made to crontab'. So it
          must be the exit status (what else ?).

          Are there any standards on what the exit status of an editor
          should be ?

          --
          Johannes
        • Bram Moolenaar
          ... This is very likely caused by the change that Vim now (by default) renames the original file to make a backup copy, and writes a new file. Crontab
          Message 4 of 9 , Oct 17, 2000
          • 0 Attachment
            Johannes Zellner wrote:

            > I just tried to `crontab -e' but crontab says
            > `no changes made to crontab' and ignores the
            > result. I retried with EDITOR=levee and it worked.
            > I don't know how crontab determines if a file
            > was modified but maybe it checks the exit
            > status of the EDITOR?

            This is very likely caused by the change that Vim now (by default) renames the
            original file to make a backup copy, and writes a new file. Crontab probably
            assumes that the editor will overwrite the original file.

            You can change this with the 'backupcopy' option.

            The problem is that crontab opens the file, invokes the editor, and then
            checks the timestamp of the file with the file descriptor it already has.
            Thus it's checking the backup file for changes...

            --
            ARTHUR: Who are you?
            TALL KNIGHT: We are the Knights Who Say "Ni"!
            BEDEVERE: No! Not the Knights Who Say "Ni"!
            "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

            /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
            \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
          • Johannes Zellner
            ... well, it s not the status. both levee and vim seem always to have exit == 0 independent of having written a buffer or not. But I still can t edit crontab
            Message 5 of 9 , Oct 17, 2000
            • 0 Attachment
              On Tue, Oct 17, 2000 at 08:32:34AM +0200, Johannes Zellner wrote:
              > I just tried to `crontab -e' but crontab says
              > `no changes made to crontab' and ignores the
              > result. I retried with EDITOR=levee and it worked.
              > I don't know how crontab determines if a file
              > was modified but maybe it checks the exit
              > status of the EDITOR?

              well, it's not the status. both levee and vim
              seem always to have exit == 0 independent of
              having written a buffer or not.

              But I still can't edit crontab with vim. I tried
              with
              export EDITOR="vim -u NONE"
              and still it does not work. This is really weird.

              Now I tried with
              export EDITOR=vim5.7
              and it works! (well, it did always).

              So it must be a vim6 problem.

              --
              Johannes
            • Rafael Garcia-Suarez
              ... Yes, backupcopy=yes fixes the behavior. The default behavior of vim may be a huge source of confusion here. Two solutions: * make backupcopy=yes the
              Message 6 of 9 , Oct 17, 2000
              • 0 Attachment
                Bram Moolenaar wrote:
                >
                > Johannes Zellner wrote:
                >
                > > I just tried to `crontab -e' but crontab says
                > > `no changes made to crontab' and ignores the
                > > result. I retried with EDITOR=levee and it worked.
                > > I don't know how crontab determines if a file
                > > was modified but maybe it checks the exit
                > > status of the EDITOR?
                >
                > This is very likely caused by the change that Vim now (by default) renames the
                > original file to make a backup copy, and writes a new file. Crontab probably
                > assumes that the editor will overwrite the original file.
                >
                > You can change this with the 'backupcopy' option.

                Yes, backupcopy=yes fixes the behavior.
                The default behavior of vim may be a huge source of confusion here.
                Two solutions:
                * make backupcopy=yes the default, and warn users that change it,
                * or, have backupcopy=auto make a backup copy when the directory where
                the edited file is is sticky (drwxrwxrwt) -- a bit kludgy.

                --
                Rafael Garcia-Suarez
              • Johannes Zellner
                ... indeed. I wasn t aware of this option. This works au BufReadPre /tmp/crontab* set bkc=yes thanks. (maybe this should go somewhere into source / runtime
                Message 7 of 9 , Oct 17, 2000
                • 0 Attachment
                  On Tue, Oct 17, 2000 at 10:15:39AM +0200, Bram Moolenaar wrote:
                  >
                  > Johannes Zellner wrote:
                  >
                  > > I just tried to `crontab -e' but crontab says
                  > > `no changes made to crontab' and ignores the
                  > > result. I retried with EDITOR=levee and it worked.
                  > > I don't know how crontab determines if a file
                  > > was modified but maybe it checks the exit
                  > > status of the EDITOR?
                  >
                  > This is very likely caused by the change that Vim now (by default) renames the
                  > original file to make a backup copy, and writes a new file. Crontab probably
                  > assumes that the editor will overwrite the original file.
                  >
                  > You can change this with the 'backupcopy' option.
                  >
                  > The problem is that crontab opens the file, invokes the editor, and then
                  > checks the timestamp of the file with the file descriptor it already has.
                  > Thus it's checking the backup file for changes...

                  indeed. I wasn't aware of this option. This works

                  au BufReadPre /tmp/crontab* set bkc=yes

                  thanks. (maybe this should go somewhere into source / runtime files ?)

                  --
                  Johannes
                • Matthew Winn
                  ... So _that_ explains why the inumbers of my files keep changing! :-) I don t think it s possible to have backupcopy=auto detect when it s safe to rename and
                  Message 8 of 9 , Oct 17, 2000
                  • 0 Attachment
                    On Tue, Oct 17, 2000 at 10:45:48AM +0200, Rafael Garcia-Suarez wrote:
                    > Yes, backupcopy=yes fixes the behavior.
                    > The default behavior of vim may be a huge source of confusion here.
                    > Two solutions:
                    > * make backupcopy=yes the default, and warn users that change it,
                    > * or, have backupcopy=auto make a backup copy when the directory where
                    > the edited file is is sticky (drwxrwxrwt) -- a bit kludgy.

                    So _that_ explains why the inumbers of my files keep changing! :-)

                    I don't think it's possible to have backupcopy=auto detect when it's
                    safe to rename and remove the original file. Consider editing a log
                    file which is held open by another process: Vim has no way to detect
                    that something else is writing to the file and will happily rename
                    and remove it while the other process continues writing to the now
                    unlinked file. I grant you it's rather scary to edit log files which
                    are in use, but it can be done and backupcopy ought not to break it
                    by default.

                    --
                    Matthew Winn (matthew@...)
                  • Bram Moolenaar
                    ... I think it s a bug in crontab. It should not rely on the editor to overwrite the original file. If find it very normal that an editor writes out modified
                    Message 9 of 9 , Oct 17, 2000
                    • 0 Attachment
                      Rafael Garcia-Suarez wrote:

                      > Bram Moolenaar wrote:
                      > > This is very likely caused by the change that Vim now (by default) renames
                      > > the original file to make a backup copy, and writes a new file. Crontab
                      > > probably assumes that the editor will overwrite the original file.
                      > >
                      > > You can change this with the 'backupcopy' option.
                      >
                      > Yes, backupcopy=yes fixes the behavior.
                      > The default behavior of vim may be a huge source of confusion here.
                      > Two solutions:
                      > * make backupcopy=yes the default, and warn users that change it,
                      > * or, have backupcopy=auto make a backup copy when the directory where
                      > the edited file is is sticky (drwxrwxrwt) -- a bit kludgy.

                      I think it's a bug in crontab. It should not rely on the editor to overwrite
                      the original file. If find it very normal that an editor writes out modified
                      text as a new file. It's a bit like "delete the old one, then write the new
                      one".

                      Anyway, when Vim behaves Vi compatible, it should use 'backupcopy' set to
                      "yes". I'll make it like that. Then "vim -u NONE" will work for crontab.

                      --
                      FATHER: Make sure the Prince doesn't leave this room until I come and
                      get him.
                      FIRST GUARD: Not ... to leave the room ... even if you come and get him.
                      FATHER: No. Until I come and get him.
                      SECOND GUARD: Hic.
                      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                      /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
                      \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
                    Your message has been successfully submitted and would be delivered to recipients shortly.