Skip to content
This repository has been archived by the owner on Jun 1, 2020. It is now read-only.

Commit

Permalink
only use timelimit to call non-built-in command
Browse files Browse the repository at this point in the history
fix #23
  • Loading branch information
PeterDaveHello committed Dec 27, 2015
1 parent 68541aa commit 060405d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions update-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,26 @@ function error()
function run()
{
echo "`date` [command] $@" >> $logPath/$logFile
timelimit -q -s 9 -t $((timeout - 2)) -T $timeout "$@"
exitStatus=$?
if [ $exitStatus -eq 137 ]; then
error "Got timeout($timeout sec) while running command: '$@'"
elif [ $exitStatus -ne 0 ]; then
error "Got error while running command: '$@'"

local isBuiltIn=false
type $1 &> /dev/null
if [ $? -eq 0 ]; then
local temp="`type $1 | head -n 1`"
if [ "$temp" = "$1 is a shell builtin" ]; then
isBuiltIn=true
fi
fi

if [ "$isBuiltIn" = "false" ]; then
timelimit -q -s 9 -t $((timeout - 2)) -T $timeout "$@"
exitStatus=$?
if [ $exitStatus -eq 137 ]; then
error "Got timeout($timeout sec) while running command: '$@'"
elif [ $exitStatus -ne 0 ]; then
error "Got error while running command: '$@'"
fi
else
"$@" || error "Got error while running command: '$@'"
fi
}

Expand Down

0 comments on commit 060405d

Please sign in to comment.