On Wed, May 9, 2018 at 9:04 AM, Christopher Browne <[email protected]> wrote:
> On Wed, 9 May 2018 at 04:00, John McKown <[email protected]> > wrote: > > To me this looks similar to a UNIX shell script. Now, going sideways for > a second, if someone wanted to create a "self contained" awk script. It > would look something like: > > > #!/bin/awk -f > > ... awk code ... > > I have found it convenient when Lisp implementations (that use ; as the > comment indicator, and where # tends to mean something quite different) > have provided something like this. > > I'd quite like it if I could start a script with > #!psql > or similar and have it be, yes, indeed, directly executable via psql. > > There are several complications that leap out at me... > ​Frankly, none of those are complications. For all the areas of concern you described the decision for desired behavior has already been made. They seem to limit the extent to which a shebang would be useful... 1. O/S PATH determines what a bare "psql" invocation finds 2. arguments override environment variables 3. \i means include, no transaction semantics And trying harder for #1 doesn't seem worthwhile - or maybe is a feature in its own right. Something like: --@ client-version >= 9.6 --@ server-version >= 9.4 If those comments are found in a file psql is evaluating it should error out if the condition doesn't match. That should apply regardless of invocation method. David J.
