GNU Bash version 5.1, WSL, Ubuntu 22.04.3 LTS.
$ bash -version
bash -version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
- Edit
.bashrc
, create functionfoo
:
foo() {
echo 'GHOST'
}
save and exit
- Source
.bashrc
:
. .bashrc
Now foo
is a valid function:
type foo
foo is a function
foo ()
{
echo 'GHOST'
}
Call
foo()
, it will printGHOST
Edit
.bashrc
, remove the function, source againfoo
as a function still available for calling andtype
.Restart a terminal window, it now stops existing.
Of course it also happens when you rename a function; and you keep calling the old version while repeating it pressing UP to use the one in history.
Bug? Feature? Exploit?