Whenever I run a sql script using Sql*plus and check for $?, I get 0 even when the script wasn\'t succesful.
Example
#$ sqlplus user/password@instanc
The best action might a combination of the other ideas on this page and the ideas at
Help with SQLPLUS please? How to make SQLPLUS startup with DEFINE `OFF` initially?
Make a login.sql file, or edit the global one to have
WHENEVER OSERROR EXIT FAILURE
WHENEVER SQLERROR EXIT SQL.SQLCODE
inside it. Then, if the file doesn't exist, it will error out. If a line fails, it will error out.
However, keep in mind that as the docs say at : https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve052.htm#SQPUG135 that certain commands still will not error out as you might expect.