I'm doing the Shellshock lab, the tutorial gives an approach to pass a function to child process by environment variable:
$ foo='() { echo "hello"; }'
$ export foo
$ /bin/bash
$ foo
hello
However, when I tried this on my Ubuntu 20.04, foo was not converted to a function in the child process.
$ foo='() { echo "hello"; }'
$ export foo
$ /bin/bash
$ foo
Command 'foo' not found, did you mean: ...
Is there anything I missed, or this approach only works for certain versions of bash?