[lug] cp and rm

David dajo at frii.com
Wed Aug 1 14:37:06 MDT 2001


   >>>>> "David" == David  <dajo at frii.com> writes:
   
   David> Personally I like the -i option; the complaint I have is that
   David> sometimes I do not seem to be able to disable it with unalias.
   
   That's curious.
   
   Are you sure it is an alias and not something else?
   Use `type foo' to see what `foo' is (if you use bash).
   
   Tom

I have reproduced the problem for you.  Here is a fragment of my
personal .bashrc, my root .bashrc with both a function that works
without prompting (backuphome) and one that does not (testitnow, which
changes /bin/cp to cp and does unalias/alias), and output from the
test.  I ran the test from a shell inside emacs 20.7.  Note the result
of "type cp" in the output.


## personal .bashrc fragment

# Directories.
alias ls="ls -F -h"
alias dir="ls -lAs | more"
alias dr="ls -l -A"
alias rm="rm -i"
alias mv='mv -i'
alias cp="cp -i"


## root .bashrc

##############################################################################
#                                                                            #
# .bashrc - root configuration file for Bash shell.                          #
#                                                                            #
# Hacked-up by dajo                                                          #
# -last-modification-date  "Wed Aug  1 14:35:21 2001"                        #
#                                                                            #
##############################################################################


source /home/dajo/.bashrc

alias  emacs="/usr/local/bin/emacs -q -l /root/.emacs -g 159x69+130+20 &"

# FVWM2 seems to require this so that it can overwrite initialisation files.
unset noclobber

# Necessary for some operations, e.g., make install for emacs.
PATH=$PATH:/sbin

# Tool.
tarandgzip  ()
    # parameter 1 is the name of the file to be created.
    # parameter 2 is the directory to be processed.
    {
        echo  "starting tarandgzip"
        date
        echo  "tarring $1"
        /bin/rm    -f   $1
        tar   -cf  $1  $2
        echo  "gzipping $1"
        gzip  -f   $1
        date
        echo  "completed tarandgzip"
    }

# Archive.
backuphome  ()
    {
        echo "archive commencing"

        mount  /Archive2  

        echo  "copying to Archive2"
        /bin/cp  -Rpf  /home/bozo            /Archive2/home
        /bin/cp  -Rpf  /home/dajo            /Archive2/home
        /bin/cp  -Rpf  /home/Nepenthes       /Archive2/home
        /bin/cp  -Rpf  /home/NewSystemFiles  /Archive2/home
        /bin/cp  -Rpf  /home/Releases        /Archive2/home

        tarandgzip  /Archive2/dajotar  /home/dajo
        tarandgzip  /Archive2/neptar   /home/Nepenthes

        umount  /Archive2

        echo  "archive complete"
    }

testitnow  ()
    {
        echo "archive commencing"

        mount  /Archive2  
unalias cp
type cp

        echo  "copying to Archive2"
        cp  -Rpf  /home/bozo            /Archive2/home
        cp  -Rpf  /home/dajo            /Archive2/home
        cp  -Rpf  /home/Nepenthes       /Archive2/home
        cp  -Rpf  /home/NewSystemFiles  /Archive2/home
        cp  -Rpf  /home/Releases        /Archive2/home

        tarandgzip  /Archive2/dajotar  /home/dajo
        tarandgzip  /Archive2/neptar   /home/Nepenthes

alias cp='cp -i'
        umount  /Archive2

        echo  "archive complete"
    }


# Output

Rednose root ~ source ./.bashrc
Rednose root ~ testitnow
archive commencing
cp is aliased to `cp -i'
cp is /bin/cp
copying to Archive2
cp: overwrite `/Archive2/home/bozo/.Xdefaults'? 
<snip>

dajo



More information about the LUG mailing list