Re: psql doesn't pass on exported shell environment functions

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'David G(dot) Johnston *EXTERN*'" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql doesn't pass on exported shell environment functions
Date: 2017-07-07 10:59:03
Message-ID: A737B7A37273E048B164557ADEF4A58B53A80042@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-07-07 13:42:23 Re: (Might be a bug) locale issue while upgrading data directory from PostgreSQL 8.4 to 9.5
Previous Message Patrick B 2017-07-07 10:49:54 Re: count records in two different table joined by