bug-bash
[Top][All Lists]
Advanced

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

Calling enable -f twice without enable -d confuses bash


From: Scott Herod
Subject: Calling enable -f twice without enable -d confuses bash
Date: 25 Nov 2002 11:51:06 -0700

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linu
x-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DSHELL
-DHAVE_CON
FIG_H   -I.  -I. -I./include -I./lib -g -O2
uname output: Linux co-herod-linux.trans.corp 2.4.18-3 #1 Thu Apr 18
07:37:53 ED
T 2002 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        If you call enable -f on a single library twice without
        unloading it with enable -d in between confuses the loader.
        Subsequent loads with enable -f only turn on the previous
        version the of the loadable, not the one most recently loaded.

Repeat-By:
        Write a bash builtin.  Load it with

        enable -f ./libmybuiltin.so mybuiltin

        Make a small change and load it again.  ( It is fun to make
        an error this time by say using an undefined object.  Notice
        on the second load you will not receive an error.)

        make libmybuiltin.so
        enable -f ./libmybuiltin.so mybuiltin

        Now unload

        enable -d mybuiltin
        It will fail to run.

        mybuiltin
        bash: mybuiltin: command not found

        Make mybuiltin correct but different from the original version
        and load it again.

        enable -f ./libmybuiltin.so mybuiltin

        mybuiltin again runs the original version.





/* builtin_tester  -- NOTE this will not compile unless the __P bug
   is fixed first. */

/* See Makefile for compilation details. */

#include <config.h>

#include <stdio.h>
#include <errno.h>

#include <iostream>
#include <string>

#if defined (HAVE_UNISTD_H)
#  include <unistd.h>
#endif

// Wrap up all of the bash headers.
extern "C" {
#include "stdc.h"

#include "bashtypes.h"
#include "posixstat.h"
#include "filecntl.h"

#include "bashansi.h"
#include "chartypes.h"

#include "builtins.h"
#include "shell.h"
#include "bashgetopt.h"
}

// Forward declaration of our external interface
extern "C" {
    int bt2_builtin ( WORD_LIST *list );
}

// Our stuff below
char *bt2_doc[] = {
    "Spam is good.",
    (char *)NULL
};

struct builtin bt2_struct = {
    "bt2",              /* builtin name */
    bt2_builtin,        /* function implementing the builtin */
    BUILTIN_ENABLED,    /* initial flags for builtin */
    bt2_doc,            /* array of long documentation strings. */
    "bt2 [options]",    /* usage synopsis; becomes short_doc */
    0                   /* reserved for internal use */
};

extern int SpamIsGood;  // Causes a load failure

int bt2_builtin ( WORD_LIST *list )
{
    if ( strcmp ( "Spam", "Spam" ) )
    {
        cerr << "They don't match" << endl;
    }
    else
    {
        cerr << "They do match" << endl;
    }

    if ( strcmp ( "Spam", "Maps" ) )
    {
        cerr << "They don't match" << endl;
    }
    else
    {
        cerr << "They do match" << endl;
    }

    // cerr << SpamIsGood << endl;

    cout << "Spam is good." << endl;
    return ( EXECUTION_SUCCESS );
}






reply via email to

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