bash refuses to interpolate arguments

I’m having problem with the following script

#!/bin/bash

if [ $# = 5 ]; then
  BASE_POPULATION_SIZE=$1
  CROSSOVER_COUNT=$2
  CROSSOVER_PAIRS=$3
  CWD=$4
  TWD=$5

  # -------------------

  FROM="0"
  TILL=$(( $CROSSOVER_COUNT * $CROSSOVER_PAIRS * 2 - 1 ))

  # -------------------

  BASE_PATH=$(cat .base-path)                                             

  STEP=$(cat .eval-step)                                                
  STEPS=$(cat .eval-steps)                                              

  ROWS=$(cat .config-dimensions-rows)                                     
  COLS=$(cat .config-dimensions-cols)                                     

  ESTIMATE_PATHS=$(cat .config-estimate-paths)
  TRANSFORM_PATH=$(cat .config-transform-path)

  MUTATION=$(cat .ga-crossover)
  INVERSION=$(cat .ga-inversion)
  CROSSOVER=$(cat .ga-crossover)

  # -------------------
  mkdir -p $TWD

  SEED=$(uuidgen)
  echo "$SEED" >$TWD/step.seed
  # -------------------

  for i in `seq $FROM $TILL`
  do
    ./eval -a RuleLoader -q -v -i $STEP -m $STEPS -o $CWD/$i.phenotype.result.rle $CWD/$i.phenotype.rle
  done
  # -------------------

  echo "mono $BASE_PATH/Step.exe $SEED $BASE_POPULATION_SIZE $MUTATION $INVERSION $CROSSOVER $CROSSOVER_COUNT $CROSSOVER_PAIRS $CWD $TWD $TRANSFORM_PATH $ESTIMATE_PATHS"
  mono $BASE_PATH/Step.exe $SEED $BASE_POPULATION_SIZE $MUTATION $INVERSION $CROSSOVER $CROSSOVER_COUNT $CROSSOVER_PAIRS $CWD $TWD $TRANSFORM_PATH $ESTIMATE_PATHS

else
  echo "invalid amount of arguments supplied"
fi

when it reaches line

./eval -a RuleLoader -q -v -i $STEP -m $STEPS -o $CWD/$i.phenotype.result.rle $CWD/$i.phenotype.rle

and tries to run it, application eval receives non-interpolated arguments, so instead of evaluating variable $STEP, $STEPS, $CWD, $i, it just passes strings “$STEP”, “STEPS”…

What’s the problem with this script?

Thank you in advance!


Source: bash

Leave a Reply