[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to overwrite a symbolic link?
From: |
Eric Blake |
Subject: |
Re: How to overwrite a symbolic link? |
Date: |
Fri, 07 May 2010 09:41:32 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Mnenhy/0.8.2 Thunderbird/3.0.4 |
On 05/07/2010 09:31 AM, Peng Yu wrote:
> On Fri, May 7, 2010 at 10:16 AM, Eric Blake <eblake@redhat.com> wrote:
>> On 05/07/2010 09:02 AM, Peng Yu wrote:
>>> Suppose I need to modify one primary file slightly to do something a
>>> little bit different. But I still need to do the original job,
>>> therefore I need to keep it the original M files. I can copy the whole
>>> directory and then modify one file in the newly copied N files. But
>>> I'll lose track of which file has been changed later on, which is
>>> important to me.
>>
>> Consider using a version control system. Track the contents of your
>> directory under your favorite VCS, like git, and then you can use
>> version control commands to generate the delta for both primary and
>> secondary files across any state that you committed.
>
> I can't use version control for
> 1. I need to frequently change file names.
> 2. Both primary and secondary files could be of hundred of MB or even GB.
git handles both of those situations, without too much hassle.
>> But overloading bash's > and >> operators is not possible.
>
> Is it because the underlying library that used in bash doesn't support
> the semantic of symbolic link that I propose? Or it is because of the
> OS?
>
> Is it possible to modify source code of bash to change the semantics
> of symbolic link.
Yes, it's possible to modify the source of bash to change how bash
treats symlinks when using the > operator. But I would advise against
it, as your fork of bash would no longer comply with POSIX, and would
probably break a lot more than it fixes. Rather, if you insist on
modifying bash, consider adding a new operator (maybe spelled '>;',
similar to the noclobber override spelling of '>|'), so that your use of
the new operator is explicit that you know what you are doing in your
scripts (if the operand of the new operator is a symlink, break the
symlink and create a file in its place instead of operating on the
target of the symlink).
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
Re: How to overwrite a symbolic link?, Marc Herbert, 2010/05/07
Re: How to overwrite a symbolic link?, Marc Herbert, 2010/05/10
Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/10
Re: How to overwrite a symbolic link?, Bob Proulx, 2010/05/10