12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/bin/bash
- DEFAULT_R=30
- DEFAULT_C=60
- R=0
- C=0
- INPUT_FILE=definitions.hpp
- trap "rm $INPUT_FILE.tmp 2> /dev/null; exit -1" SIGINT SIGTERM
- if [[ $1 == "default" ]]; then
- sed s/"#define R [0-9]*"/"#define R $DEFAULT_R"/ <$INPUT_FILE >$INPUT_FILE.tmp
- sed s/"#define C [0-9]*"/"#define C $DEFAULT_C"/ <$INPUT_FILE.tmp >$INPUT_FILE
- rm $INPUT_FILE.tmp
- make clean
- make -j4
- exit 0
- elif [[ $# -gt 0 ]]; then echo Usage: $0 "[default]"; exit 1
- else
- echo Insert new Row number \(5-120\)
- until [[ $R -ge 5 && $R -le 120 ]]; do
- read R
- if [[ $R -lt 5 || $R -gt 120 ]]; then echo Invalid size.; fi
- echo New R will be $R
- done
- echo Insert new Column number \(5-120\)
- until [[ $C -ge 5 && $C -le 120 ]]; do
- read C
- if [[ $C -lt 5 || $C -gt 120 ]]; then echo Invalid size.; fi
- echo New C will be $C
- done
- sed s/"#define R [0-9]*"/"#define R $R"/ <$INPUT_FILE >$INPUT_FILE.tmp
- sed s/"#define C [0-9]*"/"#define C $C"/ <$INPUT_FILE.tmp >$INPUT_FILE
- rm $INPUT_FILE.tmp
- make clean
- make -j4
- fi
|