test.sh:
#! /usr/bin/env bash
source "stub.bash"
type htop
stub htop
type htop
restore htop
type htop
Running it:
$ ./test.sh
htop is /usr/local/bin/htop
htop is a function
htop ()
{
echo "htop stub: $@"
}
htop is /usr/local/bin/htop
test2.sh:
#! /usr/bin/env bash
source "stub.bash"
my_name() {
echo "my name is $@"
}
type my_name
stub my_name
type my_name
restore my_name
type my_name
Running it:
$ ./test2.sh
my_name is a function
my_name ()
{
echo "my name is $@"
}
my_name is a function
my_name ()
{
echo "my_name stub: $@"
}
my_name is a function
my_name ()
{
echo "my name is $@"
}