David G. Johnston wrote:
> In hindsight I'm not surprised but couldn't find a ready explanation on the web and
> figured I'd inquire here. In short: "export VAR" and "export -f functionname" behave
> differently when psql is acting as a relay.
It works for me on Linux with 9.6.3 psql:
laurenz:~> cat psql-call-bash
#!/usr/bin/env bash
echo "Enter"
echo "EnvVar: $TEST_ENVVAR"
echo "Invoking Function..."
testfunction
exit
laurenz:~> chmod 0700 psql-call-bash
laurenz:~> function testfunction() { echo "Function Test"; }
laurenz:~> export -f testfunction
laurenz:~> export TEST_ENVVAR='Test'
laurenz:~> psql
Border style is 2.
Line style is unicode.
psql (9.6.3)
Type "help" for help.
test=> \!
laurenz:~> ./psql-call-bash
Enter
EnvVar: Test
Invoking Function...
Function Test
Yours,
Laurenz Albe