IMHO the current behavior is broken:

decibel@decina:[17:46]~/pgsql/HEAD/i$bin/psql -c 'select 1' -c 'select 2'
(1 row)

I would expect psql to either run both commands or throw an error.

What I'd personally prefer is that psql execute -c and -f (and arguably -v) in 
the order they're encountered, within the same session. I realize you can get 
the same behavior by creating a .sql file, but for simple needs that's 
sometimes more hassle than it's worth.

If we don't want to support that, we should throw an error if we encounter more 
than one -c|-f. Not doing so allows for subtle, silent breakage.

Related to this, there's a bunch of other options that should only be allowed 
once (ie: -d).

BTW, why do we special-case -? and -V at the top of main?

        if (argc > 1)
                if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 
                if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") 
== 0)
Jim C. Nasby, Data Architect             
512.569.9461 (cell)               

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to