As a workaround, I can use this shebang hack:
$ cat hello.psql
--() { :; }; exec psql -f "$0"
SELECT 'Hello World!';
$ ./hello.psql
?column?
--------------
Hello World!
(1 row)
$ psql -f hello.psql
?column?
--------------
Hello World!
(1 row)
But I would prefer to use a traditional (#!/usr/bin/env psql -f) shebang. It took a few hours on irc to hack this one together.$ cat hello.psql
--() { :; }; exec psql -f "$0"
SELECT 'Hello World!';
$ ./hello.psql
?column?
--------------
Hello World!
(1 row)
$ psql -f hello.psql
?column?
--------------
Hello World!
(1 row)
On Fri, Jul 18, 2014 at 2:28 PM, Martin Gudmundsson <martingudmundsson@xxxxxxxxx> wrote:
18 jul 2014 kl. 17:31 skrev Dennis Jenkins <dennis.jenkins.75@xxxxxxxxx>:On Fri, Jul 18, 2014 at 10:16 AM, Andrew Pennebaker <andrew.pennebaker@xxxxxxxxx> wrote:
psql -f script.psqlCould we please have the PostgreSQL lexer treat #!... on the first line of a file as a comment? This would enable .psql scripts to be run with dot-slash notation preferred by many unix users:While still allowing the traditional (and Windows compatible) style:
./script.psql
+1+1, Sounds great!Even though you can accomplish most things in other ways, this seems like the easiest in many scenarios.
--
Cheers,
Andrew Pennebaker