Just do:
#!/bin/sh
pppd call "${@:-provider}" || exit
...
or
if pppd call "${@:-provider}"; then : ; else exit; fi
If pppd fails, the script will exit and the value it returns will be that returned by pppd. (You could explicitly write exit $?, but that is the default value returned by exit when no argument is given and is not necessary.) If pppd succeeds, the script will continue.
The problem with your script (other than the ill-advised usage of exec, which I will mostly ignore) is that calling [ $? -ne 0 ] resets $?. You could re-write your script as:
#!/bin/sh
pppd call "${@:-provider}"
save_val=$?
if ! [ $save_val -eq 0 ]
then
exit $save_val
fi
but that seems excessively verbose.
Note that in your original script, you would get an error on the line if [ $? !-eq 0 ], since !-eq is not a valid operator. However, you never see that error because your early invocation of exec makes it so that line is never executed.
execisn't simply a call to a utility,execreplaces the current shell with a new one forpppd call-- it never returns. You could doif !pppd call ${@:-provider}; then exit X; fi;if you just wanted to have the current shell wait for thepppdscript to finish.