Re: Petition: Treat #!... shebangs as comments

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Petition: Treat #!... shebangs as comments
Date: 2014-07-18 15:52:59
Message-ID: 20140718155259.GD4211@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-07-18 15:58:47 Re: Petition: Treat #!... shebangs as comments
Previous Message Francisco Olarte 2014-07-18 15:51:35 Re: Petition: Treat #!... shebangs as comments