bug-bash
[Top][All Lists]
Advanced

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

unusual `unalias' behavior in shell function


From: tromey
Subject: unusual `unalias' behavior in shell function
Date: Wed, 1 Aug 2001 22:25:29 -0600

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: Linux
Compiler: gcc
Compilation CFLAGS:   -DHAVE_VFPRINTF -DHAVE_UNISTD_H -DHAVE_STDLIB_H 
-DHAVE_LIMITS_H        -DHAVE_GETGROUPS -DHAVE_RESOURCE -DHAVE_SYS_PARAM 
-DVOID_SIGHANDLER -DHAVE_GETDTABLESIZE -DHAVE_BCOPY -DHAVE_GETPW_DECLS 
-DHAVE_GETHOSTNAME -DHAVE_WAIT_H         -DHAVE_DUP2 -DHAVE_STRERROR  
-DHAVE_DIRENT_H -DHAVE_STRING_H        -DHAVE_VARARGS_H -DHAVE_STRCHR  
-DHAVE_DEV_FD        -Di386 -DLinux -DSHELL -DHAVE_ALLOCA -DHAVE_ALLOCA_H       
-O2 -m486 -fno-strength-reduce
uname output: Linux creche 2.2.16 #2 Mon Aug 28 10:13:00 MDT 2000 i686 unknown

Bash Version: 1.14
Patch Level: 7

Description:
A person on a Linux user's group mailing list I'm on pointed out
some unusual behavior of `unalias' inside a shell function.

Note that I have duplicated this bug using bash 2.04 on Red Hat Linux
7.0.

Here is a bash session showing the problem:

    creche. touch foo bar
    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

I expected the `unalias' in the function to affect the following `cp'
invocation.  Yet, seemingly, it does not.  A similar sequence sans
function works as I expect:

    creche. touch foo bar
    creche. alias cp='cp -i'
    creche. cp foo bar
    cp: overwrite `bar'? y
    creche. unalias cp
    creche. cp foo bar

Repeat-By:
        [Describe the sequence of events that causes the problem
        to occur.]

Fix:
        [Description of how to fix the problem.  If you don't know a
        fix for the problem, don't include this section.]



reply via email to

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