bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to overwrite a symbolic link?


From: Peng Yu
Subject: Re: How to overwrite a symbolic link?
Date: Sun, 9 May 2010 09:37:02 -0500

On Fri, May 7, 2010 at 10:41 AM, Eric Blake <eblake@redhat.com> wrote:
> 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).

Is there a way to define the operator '>;' without touching the bash
source code?

-- 
Regards,
Peng




reply via email to

[Prev in Thread] Current Thread [Next in Thread]