[lug] cp and rm

Tom Tromey tromey at redhat.com
Wed Aug 1 18:24:24 MDT 2001


>>>>> "David" == David  <dajo at frii.com> writes:

David> To consider the problem, reflect on this code snippet and the result.
David> type cp
David> unalias cp
David> type cp
David> cp is aliased to `cp -i'
David> cp is /bin/cp
David> copying to Archive2
David> cp: overwrite `/Archive2/home/bozo/.Xdefaults'? 

I found this interesting, so I looked into it.  I think it is a bash
bug.  Either that, or it is a weird feature and I don't understand how
bash works here.

The unalias only fails if the sequence above occurs in a shell function.
Consider this:

    creche. touch foo bar
    creche. alias cp='cp -i'
    creche. cp foo bar
    cp: overwrite `bar'? y
    creche. unalias cp
    creche. cp foo bar
    creche. 
    creche. alias cp='cp -i'
    creche. doit ()
    > {
    > type cp
    > unalias cp
    > type cp
    > cp foo bar
    > }
    creche. doit
    cp is aliased to `cp -i'
    cp is hashed (/bin/cp)
    cp: overwrite `bar'? y


This bug is in RH 6.2 (bash 1.14) and RH 7.0 (bash 2.04).
I don't think this problem has anything to do with Red Hat per se.

Tom



More information about the LUG mailing list