tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Alternative to hash-bang



Am 19.07.2014 um 02:15 schrieb D'Arcy J.M. Cain <darcy%NetBSD.org@localhost>:

> On Fri, 18 Jul 2014 19:23:17 -0400
> Greg Troxel <gdt%ir.bbn.com@localhost> wrote:
>> Once --!! happens, then there will be requests to add all sorts of
>> things, and this seems like a mess.  Surely it's easy enough to teach
> 
> As I said, '#', ';' and '--' seem to cover most situations.  Maybe '%'
> to a much smaller extent.  Can you think of many other possibilities?
> 
>> psql to ignore the first line if it starts with #!, because that's
>> obviously not valid sql.  Then it would work everywhere.
> 
> True and that's a good solution for PG.  Just thinking out loud here.

For the time being, there is a (ugly) workaround, which might be non portable, 
use the '<<' input redirection, but omit the end marker in the file, it will 
then input till the end of the file:

#!/bin/sh

psql <<EOT
\?
\c mydb
select now();



Home | Main Index | Thread Index | Old Index