From ebc1e9801490f546c4477b41647d556714a9a5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Babi=C4=8D?= Date: Fri, 24 Apr 2015 11:57:37 +0200 Subject: [PATCH] some shellcheck.net fixes --- .gitignore | 1 + robocode-svm | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 207bd61..e9d4d79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.data *.properties *.battle +*.log diff --git a/robocode-svm b/robocode-svm index 331e6a9..61cbc1d 100755 --- a/robocode-svm +++ b/robocode-svm @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -u -set -e +# set -x # File locations path="$HOME/dev/bash/robocode/svm" @@ -20,15 +20,15 @@ robot2="sample.VelociRobot" # Run battle without GUI, following the settings file, and returning the lines containing winners battle() { - echo $(robocode -nodisplay -battle "$settings" | tail -2); + robocode -nodisplay -battle "$settings" | tail -2; } # Make sure files are right -cd $path +cd "$path"; rm -f "$results"; touch "$results" # Repeat the battle desired number of times -for i in `seq 1 $rounds`; +for i in $(seq 1 $rounds); do # Generate input parameters number=$RANDOM; let "number %= $width"; x=$number @@ -44,7 +44,7 @@ robocode.battle.numRounds=1 robocode.battle.gunCoolingRate=0.1 robocode.battle.rules.inactivityTime=450 robocode.battle.selectedRobots=$robot1,$robot2 -robocode.battle.initialPositions=($(($width/2)),$(($height/2)),0),($x,$y,$alpha)" > "$settings" +robocode.battle.initialPositions=($((width/2)),$((height/2)),0),($x,$y,$alpha)" > "$settings" # If the robots are of the same name if [ "$robot1" == "$robot2" ] ; then @@ -72,5 +72,5 @@ te=$(bc <<< "scale=0; ($rounds - $tr) / 1"); # Scale the results to interval <0, 1> and split them to training set and testing set; # misuse tee for 'process substituion' and send its stdout do /dev/null -svm-scale -l 0 -u 1 "$results" | tee >(head -n $tr > "$training") >(tail -n $te > "$testing") > /dev/null +svm-scale -l 0 -u 1 "$results" | tee >(head -n "$tr" > "$training") >(tail -n "$te" > "$testing") > /dev/null