Re: Petition: Treat #!... shebangs as comments - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Petition: Treat #!... shebangs as comments
Date
Msg-id 20140718155259.GD4211@hermes.hilbert.loc
Whole thread Raw
In response to Re: Petition: Treat #!... shebangs as comments  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Petition: Treat #!... shebangs as comments  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
On Fri, Jul 18, 2014 at 08:32:53AM -0700, Adrian Klaver 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
>
> Would not doing the below accomplish the same thing for you?
>
> http://www.postgresql.org/docs/9.3/interactive/app-psql.html
>
> "Because of these legacy behaviors, putting more than one command in the -c
> string often has unexpected results. It's better to feed multiple commands
> to psql's standard input, either using echo as illustrated above, or via a
> shell here-document, for example:
>
> psql <<EOF
> \x
> SELECT * FROM foo;
> EOF
> "
>
> So:
>
> #!/bin/sh
> psql -d production -U aklaver <<EOF
> \x
> SELECT * FROM plant1;
> EOF

I think the OP is talking about executable scripts so both of

    $> psql -f the-file.sql

and

    $> ./the-file.sql

    (where the-file.sql starts with "#!/usr/bin/env psql")

would work given that the-file.sql has got execute permission.

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: Petition: Treat #!... shebangs as comments
Next
From: Adrian Klaver
Date:
Subject: Re: Petition: Treat #!... shebangs as comments