[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to overwrite a symbolic link?
From: |
Bob Proulx |
Subject: |
Re: How to overwrite a symbolic link? |
Date: |
Thu, 6 May 2010 16:36:35 -0600 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Peng Yu wrote:
> Is there a way to overload operators like '>' and '>>' in bash, just
> as overloading in C++, etc. Suppose I have already made some bash
> program using '>' and '>>' without thinking about symbolic link, but I
> begin aware of them later. I would be cumbersome to add a test
> statement and deciding whether 'rm' or not for each usage of '>' and
> '>>'.
It sounds to me like you are trying to implement a "script space"
version of copy-on-write semantics? Perhaps you should investigate
using one of the filesystem based solutions. It would probably give
you a better result.
> A more general question is how to change the behavior of a program
> (for example compiled from C code) to delete symbolic link and write a
> new file, without recompiling the program.
A Comment: Symbolic links are designed to be transparent. Normal
programs are not aware of them.
You could probably create an LD_PRELOAD library to intercept file
modification calls and then handle them in your own code. But I think
it would be difficult to do it all completely correctly and not to
introduce bugs. I advise against it.
Bob
Re: How to overwrite a symbolic link?, Marc Herbert, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/07
- Re: How to overwrite a symbolic link?, Eric Blake, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/07
- Re: How to overwrite a symbolic link?, Eric Blake, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/09
- Re: How to overwrite a symbolic link?, Chet Ramey, 2010/05/09