Here is rc, which absorbed most of that behavior from the v8 shell:

% rc

% fn f { echo hi }

% whatis f

fn f {echo hi}

% whatis path

path=(. /Users/r/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/go/bin /Applications/Keybase.app/Contents/SharedSupport/bin /usr/local/plan9/bin)

% rc

% # subshell

% f

hi

% 




On Sun, Feb 9, 2020 at 10:11 AM Rob Pike <robpike@gmail.com> wrote:
Not for me it doesn't.

% bash

bash-3.2$ function f() {

    echo hi

    }

bash-3.2$ export f

bash-3.2$ bash

bash-3.2$ f

bash-3.2$ 


I added the 'builtin' command, which did leave the labs. But I added it as a way for the "whatis" command to show a builtin, as well as allowing a way to guarantee you get the builtin on execution.


How do I get bash to print the function as (shell) source code, so I could edit it and play with it again? It was the synergy of all this stuff connected seamlessly that made it so compelling.


-rob



On Sun, Feb 9, 2020 at 10:02 AM Chet Ramey <chet.ramey@case.edu> wrote:
On 2/8/20 5:54 PM, Rob Pike wrote:
> Like exportable functions and output that's valid input, so it works well
> with an editable typescript.

Bash has both of those things.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/