简体   繁体   中英

converting bash script to .bat

#!/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.Contestant"
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM