IMHO the current behavior is broken:
decibel@decina:[17:46]~/pgsql/HEAD/i$bin/psql -c 'select 1' -c 'select 2'
?column?
----------
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], "-?") ==
0)
{
usage();
exit(EXIT_SUCCESS);
}
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V")
== 0)
{
showVersion();
exit(EXIT_SUCCESS);
}
}
--
Jim C. Nasby, Data Architect [email protected]
512.569.9461 (cell) http://jim.nasby.net
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers