[Ovirt-devel] [PATCH node] o-c-setup now catches and reports failures from called sub-scripts

Jim Meyering jim at meyering.net
Mon Jan 19 13:30:54 UTC 2009


Perry Myers <pmyers at redhat.com> wrote:
> diff --git a/scripts/ovirt-config-setup b/scripts/ovirt-config-setup
> index 21e6b0e..3d1292f 100755
> --- a/scripts/ovirt-config-setup
> +++ b/scripts/ovirt-config-setup
> @@ -40,7 +40,15 @@ while true; do
>                  "$CONTINUE") exit 0 ;;
>                  *)
>                      clear;
> -                    $CONFIG_DIR/*"$OPTION" 2>&1 | $TEE;
> +                    {
> +                        $CONFIG_DIR/*"$OPTION"
> +                        if [ $? = 0 ]; then
> +                            printf "\n$OPTION Completed Successfully\n\n"
> +                        else
> +                            printf "\nERROR: $OPTION FAILED. "
> +                            printf "See $OVIRT_LOGFILE\n\n"
> +                        fi
> +                    } 2>&1 | $TEE;
>                      break ;;
>              esac
>          done

ACK, but put command and result-test on the same line, e.g.,
use this (also factoring out the printing and formatting):

                           if $CONFIG_DIR/*"$OPTION; then
                               msg="$OPTION Completed Successfully"
                           else
                               msg="ERROR: $OPTION FAILED. See $OVIRT_LOGFILE"
                           fi
                           printf "\n%s\n\n" "$msg"
or this:

                           $CONFIG_DIR/*"$OPTION \
                             && msg="$OPTION Completed Successfully" \
                             || msg="ERROR: $OPTION FAILED. See $OVIRT_LOGFILE"
                           printf "\n%s\n\n" "$msg"




More information about the ovirt-devel mailing list