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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Petition: Treat #!... shebangs as comments
Date: 2014-07-18 22:23:23
Message-ID: 11970.1405722203@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> On Fri, Jul 18, 2014 at 3:53 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> It's not just that it's "not high on anyone's priority list", it's that
>> we'd want to be sure that the patch didn't break any existing use-cases
>> or make things unmaintainable. (This isn't exactly a negligible concern
>> considering that Postgres thinks #! is a legal operator name.)

> I think the operator objection is specious -- ISTM there is no
> scenario where an operator could be legally parsed without seeing a
> keyword first.

[ pokes at it... ] Yeah, perhaps so. I had been thinking that it might
be possible for a SQL command to be continued across files, but the way
psql's MainLoop works, that's not the case. If you do something like

SELECT 42
\i foo
;

whatever is read from foo is sent to the backend separately, it's not
folded into the outer file's SELECT. So this may be a non-problem,
at least till such time as somebody wishes they could change that.

> OTOH (recalling the BOM discussion), the situation with stdin is
> hopeless -- only psql -f or \i could strip out the shebang.

Right, but the use-case for this is (I suppose)

#! /path/to/psql -f

which according to the shell docs I'm looking at will result in
"./foo.sql other-args" turning into

/path/to/psql -f ./foo.sql other-args

So it seems like it could work, and the complaint about needing additional
connection parameters isn't that strong either.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Avni 2014-07-18 23:44:25 High Disk Utilization on Master with Streaming Replication Running 9.2.4
Previous Message Merlin Moncure 2014-07-18 21:12:33 Re: Petition: Treat #!... shebangs as comments