psql exit status varies for scripts on STDIN
От | Jeffrey W. Baker |
---|---|
Тема | psql exit status varies for scripts on STDIN |
Дата | |
Msg-id | 1095137416.4060.1.camel@localhost.localdomain обсуждение исходный текст |
Ответы |
Re: psql exit status varies for scripts on STDIN
|
Список | pgsql-general |
I just noticed something unexpected when using psql. I had written a shell script to bulk-load some hundreds of files into a database, and move each file to success/ or failure/ directories depending on the exit status. The problem is psql exit status differs depending on if the SQL script is provided with -c or on STDIN. Try this for example: $ echo "your mom" | psql ERROR: syntax error at or near "your" at character 1 $ echo $? 0 The script failed, but the exit status is 0 (success) anyway. $ psql -c "your mom" ERROR: syntax error at or near "your" at character 1 $ echo $? 1 If the same command is given with -c, the exit status indicates failure. The workaround in this case was to provide "COPY table FROM STDIN;" as the -c COMMAND and to pipe the data in on STDIN. But simply adding the COPY statement to the top of the input doesn't work right, with respect to the exit status. psql should probably give the same exit status in this case. Do you agree? -jwb
В списке pgsql-general по дате отправления: