On Mon, Mar 05, 2001 at 07:17:18PM +0000, Padraig Brady wrote:
> Hmm.. useful until you actually want to modify a linked file,
> but then your modifying the file in all "merged" trees.

Use emacs, because you can configure it to do something
appropriate with linked files.  But for those of us addicted
to vi, the attached wrapper script is pretty cool, too.





dave...

#!/bin/bash
#
# copy-on-write wrapper for hard linked files
# Copyright 2000 David A. Schleef <[EMAIL PROTECTED]>
#
# Please send me any improvments you make to this script.  I just
# wrote it as a quick and dirty hack.


linkedfiles=

for each in $*
do
        case $each in
        -*)
                # ignore
                ;;
        *)
                if [ -f "$each" ];then
                        nlinks=$(stat $each|grep Links|sed 's/.*Links: 
\(.*\)\{1\}/\1/')
                        if [ $nlinks -gt 1 ];then
                                #echo unlinking $each
                                linkedfiles="$linkedfiles $each"
                                mv $each $each.orig
                                cp $each.orig $each
                        fi
                fi
                ;;
        esac
done

/usr/bin/vim $*

for each in $linkedfiles
do
        if cmp $each $each.orig &>/dev/null
        then
                #echo relinking $each
                rm $each
                mv $each.orig $each
        fi
done

Reply via email to