Changeset 1174 for rpmbuild-bot


Ignore:
Timestamp:
Jun 7, 2017, 6:12:37 PM (8 years ago)
Author:
dmik
Message:

rpmbuild-bot: Fix capturing rpmbuild errors in -l mode.

The final message would report a successful build even if rpmbuild
failed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rpmbuild-bot/rpmbuild-bot.sh

    r1159 r1174  
    254254  rm -f "$log"
    255255  if [ -n "$log_to_console" ] ; then
    256     "$@" 2>&1 | tee "$log"
     256    # Do some magic redirection to preserve original error code
     257    # (https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash)
     258    exec 4>&1
     259    local rc=`{ { "$@" 2>&1 3>&-; printf $? 1>&3; } 4>&- | tee "$log" 1>&4; } 3>&1`
     260    exec 4>&-
    257261  else
    258262    "$@" >"$log" 2>&1
    259   fi
    260   local rc=$?
     263    local rc=$?
     264  fi
    261265  if [ $rc != 0 ] ; then
    262266    log "ERROR: The following command failed with error code $rc:"
Note: See TracChangeset for help on using the changeset viewer.