Artificial intelligent assistant

Can I "export" functions in bash? source some_file some_file: doit () { echo doit $1 } export TEST=true If I source **some_file** the function "doit" and the variable TEST are available on the command line. But running this script: script.sh: #/bin/sh echo $TEST doit test2 Will return the value of TEST, but will generate an error about the unknown function "doit". Can I "export" the function, too, or do I have to source some_file in script.sh to use the function there?

In Bash you can export function definitions to other shell scripts that your script calls with


export -f function_name


For example you can try this simple example:

### `./script1`:


#!/bin/bash

myfun() {
echo "Hello!"
}

export -f myfun
./script2


### `./script2`:


#!/bin/bash

myfun


Then if you call `./script1` you will see the output _Hello!_.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2eb439f7a6470845e7c1b258637fc2bb