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.



On Fri, Jul 18, 2014 at 2:28 PM, Martin Gudmundsson <
martingudmunds...@gmail.com> wrote:

>
> 18 jul 2014 kl. 17:31 skrev Dennis Jenkins <dennis.jenkins...@gmail.com>:
>
> On Fri, Jul 18, 2014 at 10:16 AM, Andrew Pennebaker <
> andrew.penneba...@gmail.com> wrote:
>
>> Could 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:
>>
>> ./script.psql
>>
>> While still allowing the traditional (and Windows compatible) style:
>>
>> psql -f 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
www.yellosoft.us

Reply via email to