Amber
Amber copied to clipboard
✨ [Feature request] allow export amber function as bash function
since that we could source this compiled bash script and call amber function in bash script or shell. and has a way to enhance/replace old bash script.
do you want something like this?
export pub fun say_hi() {
echo "hi!"
}
to compile into
say_hi() { # name preserved
echo "hi!"
}
export -f say_hi
@b1ek We could unify this with the proposed syntax in this issue https://github.com/Ph0enixKM/Amber/issues/68 with export
export pub fun foo() {
echo "Hello"
}
export FOO = "Env variable"
bash:
# Amber function accessible from Amber itself
_AF_foo_v0() {
echo "Hello"
}
# Renamed Amber function for export
foo() {
# Call the Amber function
_AF_foo_v0 "$@"
# Echo the result that it returns
echo "${_AF_foo_v0__0}"
# Return the same exit code (if not failable - return 0)
return 0
}
# Export the function with the name
export -f foo
# Export the environment variable
export FOO="Env variable"
Closing as duplicate of https://github.com/amber-lang/amber/issues/253