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

Problem editing file with multiple links

Expand Messages
  • Jonathan B. Bayer
    Hello Jasspa, I just ran into a situation where I had to edit a shell script with multiple links. The edit worked, but when it saved the file, it broke the
    Message 1 of 4 , Oct 16, 2009
    • 0 Attachment
      Hello Jasspa,

      I just ran into a situation where I had to edit a shell script with
      multiple links. The edit worked, but when it saved the file, it broke
      the links. The original link was renamed with a tilde at the end, and
      it saved the edited file as a new file.

      This is a problem, how can I stop this from happening. I'd like to
      change it so that it copies the original, and then saves the file over
      the original.


      Thanks in advance


      JBB
      ---
      Jonathan B. Bayer

      mailto:jbayer@...
    • Steven Phillips
      Problem here is that copy often changes the properties of the file, from date create & last modified to file permissions, and this properties would then be
      Message 2 of 4 , Oct 16, 2009
      • 0 Attachment
        Problem here is that copy often changes the properties of the file, from
        date create & last modified to file permissions, and this properties
        would then be permanently lost as the newly created file of the same
        name would not inherit these properties (and rightly so). So ME
        currently does the right thing.

        But the question I have is what platform are you using? Every unix
        system I have used would not modify a symbolic link if the file it
        pointed to was renamed, it would simply leave it dangling, this looks
        more like a broken OS, trying to be too smart, than an ME bug!

        Steve

        Jonathan B. Bayer wrote:
        > Hello Jasspa,
        >
        > I just ran into a situation where I had to edit a shell script with
        > multiple links. The edit worked, but when it saved the file, it broke
        > the links. The original link was renamed with a tilde at the end, and
        > it saved the edited file as a new file.
        >
        > This is a problem, how can I stop this from happening. I'd like to
        > change it so that it copies the original, and then saves the file over
        > the original.
        >
        >
        > Thanks in advance
        >
        >
        > JBB
        > ---
        > Jonathan B. Bayer
        >
        > mailto:jbayer@...
        >
        >
        >
        > ------------------------------------
        >
        > __________________________________________________________________________
        >
        > This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
        > any material posted to this list.
        >
        > To un-subscribe, send a mail message to
        >
        > mailto:jasspa-unsubscribe@yahoogroups.com
        >
        > or visit http://groups.yahoo.com/group/jasspa and
        > modify your account settings manually.
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
      • Jon Green
        ... I think the problem is possibly when editing a symbolic link as to whether the link should be resolved first before the edit operation is performed. This
        Message 3 of 4 , Oct 17, 2009
        • 0 Attachment
          Steven Phillips wrote:
          > Problem here is that copy often changes the properties of the file, from
          > date create & last modified to file permissions, and this properties
          > would then be permanently lost as the newly created file of the same
          > name would not inherit these properties (and rightly so). So ME
          > currently does the right thing.
          >
          > But the question I have is what platform are you using? Every unix
          > system I have used would not modify a symbolic link if the file it
          > pointed to was renamed, it would simply leave it dangling, this looks
          > more like a broken OS, trying to be too smart, than an ME bug!
          >
          > Steve
          >

          I think the problem is possibly when editing a symbolic link as to whether the
          link should be resolved first before the edit operation is performed. This
          would involve changing directories to the origin of the link and then
          performing the edit operation.

          In some instances you might want this behaviour in others then you might not so
          there is not a clear cut decision either way as to what is best. i.e. I would
          want the current behaviour if I had created a symbolic link as a temporary fix
          to include some sort of file or directory. Conversely if I really wanted to
          edit the file at the end of the symbolic link then I would require the link to
          be resolved before I edited it.

          So I kind of think the behaviour at the moment is probably the correct
          behaviour and is certainly the safest. If you are editing a file that is a
          symbolic link then you should be editing it in the correct place (i.e. the
          original location) rather than an instance of it. Most of the symbolic links
          typically appear in the system directories such as /etc and one really does not
          want to be dealing with ambiguities of what file is what at this level.

          That is my 10c anyway.

          Regards
          Jon.

          > Jonathan B. Bayer wrote:
          >> Hello Jasspa,
          >>
          >> I just ran into a situation where I had to edit a shell script with
          >> multiple links. The edit worked, but when it saved the file, it broke
          >> the links. The original link was renamed with a tilde at the end, and
          >> it saved the edited file as a new file.
          >>
          >> This is a problem, how can I stop this from happening. I'd like to
          >> change it so that it copies the original, and then saves the file over
          >> the original.
          >>
          >>
          >> Thanks in advance
          >>
          >>
          >> JBB
          >> ---
          >> Jonathan B. Bayer
          >>
          >> mailto:jbayer@...
          >>
          >>
          >>
          >> ------------------------------------
          >>
          >> __________________________________________________________________________
          >>
          >> This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
          >> any material posted to this list.
          >>
          >> To un-subscribe, send a mail message to
          >>
          >> mailto:jasspa-unsubscribe@yahoogroups.com
          >>
          >> or visit http://groups.yahoo.com/group/jasspa and
          >> modify your account settings manually.
          >>
          >>
          >> Yahoo! Groups Links
          >>
          >>
          >>
          >>
          >>
          >
          >
          >
          > ------------------------------------
          >
          > __________________________________________________________________________
          >
          > This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
          > any material posted to this list.
          >
          > To un-subscribe, send a mail message to
          >
          > mailto:jasspa-unsubscribe@yahoogroups.com
          >
          > or visit http://groups.yahoo.com/group/jasspa and
          > modify your account settings manually.
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
        • Jonathan B. Bayer
          Hello Steven, This file wasn t a symbolic link, it was a regular link. With a regular link, the same inode is referenced by multiple directory entries. By
          Message 4 of 4 , Oct 18, 2009
          • 0 Attachment
            Hello Steven,

            This file wasn't a symbolic link, it was a regular link. With a
            regular link, the same inode is referenced by multiple directory
            entries. By first renaming the file, the other directory entries are
            now pointing to the renamed file. This breaks the intended linkage.



            Ubuntu 9.04




            JBB

            Friday, October 16, 2009, 2:04:07 PM, you wrote:

            SP> Problem here is that copy often changes the properties of the file, from
            SP> date create & last modified to file permissions, and this properties
            SP> would then be permanently lost as the newly created file of the same
            SP> name would not inherit these properties (and rightly so). So ME
            SP> currently does the right thing.

            SP> But the question I have is what platform are you using? Every unix
            SP> system I have used would not modify a symbolic link if the file it
            SP> pointed to was renamed, it would simply leave it dangling, this looks
            SP> more like a broken OS, trying to be too smart, than an ME bug!

            SP> Steve

            SP> Jonathan B. Bayer wrote:
            >> Hello Jasspa,
            >>
            >> I just ran into a situation where I had to edit a shell script with
            >> multiple links. The edit worked, but when it saved the file, it broke
            >> the links. The original link was renamed with a tilde at the end, and
            >> it saved the edited file as a new file.
            >>
            >> This is a problem, how can I stop this from happening. I'd like to
            >> change it so that it copies the original, and then saves the file over
            >> the original.
            >>
            >>
            >> Thanks in advance
            >>
            >>
            >> JBB
            >> ---
            >> Jonathan B. Bayer
            >>
            >> mailto:jbayer@...
            >>
            >>
            >>
            >> ------------------------------------
            >>
            >> __________________________________________________________________________
            >>
            >> This is an unmoderated list, but new members are moderated to ensure that there are no spam users. JASSPA is not responsible for the content of
            >> any material posted to this list.
            >>
            >> To un-subscribe, send a mail message to
            >>
            >> mailto:jasspa-unsubscribe@yahoogroups.com
            >>
            >> or visit http://groups.yahoo.com/group/jasspa and
            >> modify your account settings manually.
            >>
            >>
            >> Yahoo! Groups Links
            >>
            >>
            >>
            >>
            >>



            SP> ------------------------------------

            SP> __________________________________________________________________________

            SP> This is an unmoderated list, but new members are moderated to
            SP> ensure that there are no spam users. JASSPA is not responsible for the content of
            SP> any material posted to this list.

            SP> To un-subscribe, send a mail message to

            SP> mailto:jasspa-unsubscribe@yahoogroups.com

            SP> or visit http://groups.yahoo.com/group/jasspa and
            SP> modify your account settings manually.


            SP> Yahoo! Groups Links







            JBB
            ---
            Jonathan B. Bayer

            mailto:jbayer@...
          Your message has been successfully submitted and would be delivered to recipients shortly.