#!/bin/bash
function usage(){
cat <<EOF
USAGE: $0 [strategylist]
valid strategies are:
ALLD
ALLC
TitForTat
JOSS
WeightedRandom
Tester
EOF
exit 1
}
[ -z $1 ] && usage
javac robsAgents/*.java robsAgents/behaviours/*.java
agentlist='leader:robsAgents.TournamentLeader'
agentlist=$agentlist";$1:robsAgents.Contestant"
while shift;
do
agentlist=$agentlist";$1:robsAgents.Conte开发者_高级运维stant"
done
java jade.Boot -gui -host 127.0.0.1 "$agentlist"
i have above bash script and have no access to a windows computer and i need to convert it to a .bat file, but don't even know how to do the shift and argument parsing
How to use shift in batch:
:Loop
if "%1"=="" goto End
use %1 here
shift
goto Loop
:End
Although giving this obvious answer tends to annoy people, it's really not bad advice and totally solves the bash-portability problem: install Cygwin on the TA's machine.
Yes, installing Cygwin is way overkill for many of the little problems posted. But the install is quick, easy, and online, and the installer gets years of small and large problems solved. It seems like a win to me.
My apologies to the Cygwin-suspicious.
精彩评论