Statistics
| Branch: | Tag: | Revision:

amiro-blt / setup.sh @ 7a91596e

History | View | Annotate | Download (21.7 KB)

1
################################################################################
2
# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
3
# Robot (AMiRo) platform.                                                      #
4
# Copyright (C) 2016..2017  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

    
24
#!/bin/bash
25

    
26
################################################################################
27
# GENERIC FUNCTIONS                                                            #
28
################################################################################
29

    
30
### print an error
31
# arguments:
32
#   - error string [required]
33
# return: n/a
34
function printError {
35
  local string="ERROR:   $1"
36

    
37
  # if a log file is specified
38
  if [ ! -z $LOG_FILE ]; then
39
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
40
  fi
41
  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
42
}
43

    
44
### print a warning
45
# arguments:
46
#   - warning string [required]
47
# return: n/a
48
function printWarning {
49
  local string="WARNING: $1"
50

    
51
  # if a log file is specified
52
  if [ ! -z $LOG_FILE ]; then
53
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
54
  fi
55
  printf "$(tput setaf 3)>>> $string$(tput sgr 0)" 1>&2
56
}
57

    
58
### print an information text
59
# arguments:
60
#   - information string [required]
61
# return: n/a
62
function printInfo {
63
  local string="INFO:    $1"
64

    
65
  # if a log file is specified
66
  if [ ! -z $LOG_FILE ]; then
67
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
68
  fi
69
  printf "$(tput setaf 2)>>> $string$(tput sgr 0)" 1>&2
70
}
71

    
72
### print a message to the log file
73
# arguments:
74
#   - information string [required]
75
# return: n/a
76
function printLog {
77
  local string="LOG:     $1"
78

    
79
  # if a log file is specified
80
  if [ ! -z $LOG_FILE ]; then
81
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
82
  fi
83
}
84

    
85
### exit the script normally
86
# arguments: n/a
87
# return: 0 (success)
88
function quitScript {
89
  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
90
  printf "\n"
91
  printf "######################################################################\n"
92

    
93
  exit 0
94
}
95

    
96
### read a user input
97
# arguments:
98
#   --numchars, -n  maximum number of characters to read
99
#   --options, -o   possible chacters to select (only applies if numchars=1)
100
#   --out, -e       output variable to store the user input to
101
# return: error code
102
#   -  0: no error
103
#   - -1: error: invalid arguments
104
function readUserInput {
105
  # parse arguments
106
  local arguments=$(getopt -l num-chars:,options:,out: -o n:o:e: -- "$@")
107
  if [ $? != 0 ]; then
108
    printError "could not interprete arguments."
109
    return -1
110
  fi
111
  eval set -- "$arguments"
112

    
113
  # evaluate arguments
114
  local numchars=0
115
  local options=""
116
  local outvar=""
117
  while [ true ]; do
118
    case "$1" in
119
      --num-chars|-n)
120
        numchars=$2; shift 2
121
        ;;
122
      --options|-o)
123
        options="$2"; shift 2
124
        ;;
125
      --out|-e)
126
        outvar=$2; shift 2
127
        ;;
128
      --) # end of options reached
129
        shift; break
130
        ;;
131
      *) # sanity check (return error)
132
        printError "unexpected argument: $1\n"; return -1
133
        ;;
134
    esac
135
  done
136

    
137
  # read user input
138
  local _userinput=""
139
  while [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); do
140
    if [ $numchars == 0 ]; then
141
      read -p "your selection: " -e _userinput
142
    else
143
      read -p "your selection: " -n $numchars -e _userinput
144
    fi
145
    if [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); then
146
      printWarning "[$_userinput] is no valid action\n"
147
    fi
148
  done
149
  printLog "[$_userinput] has been selected\n"
150
  if [ ! -z "$outvar" ]; then
151
    eval $outvar="$_userinput"
152
  fi
153

    
154
  return 0
155
}
156

    
157
### set the log file
158
# arguments:
159
#   --file, -f    name of file [required]
160
#   --option, -o  option if file already exists [optional]
161
#                 a: append
162
#                 r: delete and restart
163
#                 n: disable log
164
#                 A: silent append (no message in the log file)
165
# return: error code
166
#   -  0: no error
167
#   -  1: warning: file already exists
168
#   -  2: warning: no file specified
169
#   - -1: error: invalid arguments
170
function setLogFile {
171
  # parse arguments
172
  local arguments=$(getopt -l file:,option: -o f:o: -- "$@")
173
  if [ $? != 0 ]; then
174
    printError "could not interprete arguments."
175
    return -1
176
  fi
177
  eval set -- "$arguments"
178

    
179
  # evaluate arguments
180
  local fname=""
181
  local option=""
182
  while [ true ]; do
183
    case "$1" in
184
      --file|f)
185
        if [ ! -z $2 ]; then
186
          fname="$(dirname $2)/$(basename $2)"
187
        else
188
          fname=""
189
        fi
190
        shift 2
191
        ;;
192
      --option|-o)
193
        case $2 in
194
          A)
195
            option="A"
196
            ;;
197
          a)
198
            option="a"
199
            ;;
200
          r)
201
            option="r"
202
            ;;
203
          n)
204
            option="n"
205
            ;;
206
          *) # sanity check (return error)
207
            printError "unexpected argument: $1\n"; return -1
208
            ;;
209
        esac
210
        shift 2
211
        ;;
212
      --) # end of options reached
213
        shift; break
214
        ;;
215
      *) # sanity check (return error)
216
        printError "unexpected argument: $1\n"; return -1
217
        ;;
218
    esac
219
  done
220

    
221
  # if no log file was specified
222
  if [ -z $fname ]; then
223
    printWarning "no log file specified (no log will be genreated)\n"
224
    LOG_FILE=""
225
    return 2
226
  # if file already exists
227
  elif [ -f $fname ]; then
228
    # if no option was specified, ask what to do
229
    if [ -z $option ]; then
230
      printWarning "log file ${fname} already esists\n"
231
      printf "Options:\n"
232
      printf "  [A] - append log\n"
233
      printf "  [R] - restart log (delete existing file)\n"
234
      printf "  [N] - no log\n"
235
      readUserInput --num-chars=1 --options="AaRrNn" --out=userinput
236
      option=${userinput,,}
237
    fi
238

    
239
    # evaluate option
240
    case $option in
241
      A)
242
        LOG_FILE=$(realpath $fname)
243
        ;;
244
      a)
245
        printInfo "appending log to existing file\n"
246
        LOG_FILE=$(realpath $fname)
247
        printf "\n" >> $LOG_FILE
248
        printf "######################################################################\n" >> $LOG_FILE
249
        printf "\n" >> $LOG_FILE
250
        ;;
251
      r)
252
        printInfo "old log file deleted, starting clean\n"
253
        LOG_FILE=$(realpath $fname)
254
        rm $LOG_FILE
255
        ;;
256
      n)
257
        printInfo "no log file will be generated\n"
258
        LOG_FILE=""
259
        ;;
260
      *) # sanity check (return error)
261
        printError "unexpected argument: $1\n"; return -1
262
        ;;
263
    esac
264

    
265
    return 1
266
  else
267
    printInfo "log file set to $(realpath $fname)\n"
268
    LOG_FILE=$(realpath $fname)
269
    return 0
270
  fi
271
}
272

    
273
################################################################################
274
# SPECIFIC FUNCTIONS                                                           #
275
################################################################################
276

    
277
### print welcome text
278
# arguments: n/a
279
# return: n/a
280
function printWelcomeText {
281
  printf "######################################################################\n"
282
  printf "#                                                                    #\n"
283
  printf "#                  Welcome to the AMiRo-BLT setup!                   #\n"
284
  printf "#                                                                    #\n"
285
  printf "######################################################################\n"
286
  printf "#                                                                    #\n"
287
  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
288
  printf "#                                                                    #\n"
289
  printf "# This is free software; see the source for copying conditions.      #\n"
290
  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
291
  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
292
  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
293
  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
294
  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
295
  printf "# Excellence Initiative.                                             #\n"
296
  printf "#                                                                    #\n"
297
  printf "######################################################################\n"
298
}
299

    
300
### print help text
301
# arguments: n/a
302
# return: n/a
303
function printHelp {
304
  printInfo "printing help text\n"
305
  printf "usage:  $(basename ${BASH_SOURCE[0]}) [options]\n"
306
  printf "options:\n"
307
  printf "  --help, -h        Print this help text.\n"
308
  printf "  --stm32flash, -f  Run stm32flash tool setup.\n"
309
  printf "  --SerialBoot, -s  Run SerialBoot tool setup.\n"
310
  printf "  --IDE, -e         Enter IDE setup.\n"
311
  printf "  --quit, -q        Quit the script.\n"
312
  printf "  --log=<file>      Specify a log file.\n"
313
}
314

    
315
### enter bootloader setup
316
# arguments n/a
317
# return:
318
#  -  0: no error
319
#  -  1: warning: function aborted by user
320
#  - -1: error: unexpected user input
321
function stm32flashSetup {
322
  local stm32flashdir=$(dirname $(realpath ${BASH_SOURCE[0]}))/Host/Source/stm32flash/
323

    
324
  # if the stm32flash folder is not empty
325
  if [ ! -z "$(ls -A $stm32flashdir)" ]; then
326
    printWarning "$(realpath $stm32flashdir) is not empty. Delete and reinitialize? [y/n]\n"
327
    readUserInput --num-chars=1 --options="YyNn" --out=userinput
328
    case $userinput in
329
      Y|y)
330
        printInfo "wiping $stm32flashdir\n"
331
        git submodule deinit -f $stm32flashdir 2>&1 | tee -a $LOG_FILE
332
        ;;
333
      N|n)
334
        printWarning "stm32flash setup aborted by user\n"
335
        return 1
336
        ;;
337
      *) # sanity check (return error)
338
        printError "unexpected input: $userinput\n";
339
        return -1
340
        ;;
341
    esac
342
  fi
343

    
344
  # initialize submodule
345
  printInfo "initializing stm32flash submodule\n"
346
  git submodule update --init $stm32flashdir 2>&1 | tee -a $LOG_FILE
347

    
348
  # build the stm32flash tool
349
  printInfo "compiling stm32flash\n"
350
  userdir=${PWD}
351
  cd "$stm32flashdir"
352
  make 2>&1 | tee -a $LOG_FILE
353
  cd "$userdir"
354

    
355
  return 0
356
}
357

    
358
### enter SerialBoot setup
359
# arguments n/a
360
# return:
361
#  -  0: no error
362
#  -  1: warning: function aborted by user
363
#  - -1: error: unexpected user input
364
function serialBootSetup {
365
  local serialbootdir=$(dirname $(realpath ${BASH_SOURCE[0]}))/Host/Source/SerialBoot/
366

    
367
  # if a build folder already exists
368
  if [ -d "${serialbootdir}/build/" ]; then
369
    printWarning "SerialBoot has been built before. Delete and rebuild? [y/n]\n"
370
    readUserInput --num-chars=1 --options="YyNn" --out=userinput
371
    case $userinput in
372
      Y|y)
373
        printInfo "deleting ${serialbootdir}build/\n"
374
        rm -rf "${serialbootdir}build/"
375
        ;;
376
      N|n)
377
        printWarning "SerialBoot setup aborted by user\n"
378
        return 1
379
        ;;
380
      *) # sanity check (return error)
381
        printError "unexpected input: $userinput\n";
382
        return -1
383
        ;;
384
    esac
385
  fi
386

    
387
  # build SerialBoot
388
  printInfo "compiling SerialBoot\n"
389
  local userdir=${PWD}
390
  mkdir "${serialbootdir}build/"
391
  cd "${serialbootdir}build/"
392
  cmake .. 2>&1 | tee -a $LOG_FILE
393
  make 2>&1 | tee -a $LOG_FILE
394
  cd "$userdir"
395

    
396
  return 0
397
}
398

    
399
### enter IDE setup
400
# arguments n/a
401
# return: n/a
402
function ideSetup {
403
  printInfo "entering ideSetup setup\n"
404
  printf "\n"
405
  if [ -z $LOG_FILE ]; then
406
    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/setup_IDE.sh --noinfo
407
  else
408
    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/setup_IDE.sh --LOG="$LOG_FILE" --noinfo
409
  fi
410
}
411

    
412
################################################################################
413
# SCRIPT MAIN FUNCTION                                                         #
414
################################################################################
415

    
416
### main function of this script
417
# arguments: see help text
418
# return: error code
419
#   - 0: no error
420
#   - 1: error
421
function main {
422

    
423
  # parse arguments
424
  local arguments=$(getopt -l help,stm32flash,SerialBoot,IDE,quit,log:,LOG:,noinfo -o hfseq -- "$@")
425
  if [ $? != 0 ]; then
426
    printError "could not interprete arguments."
427
    exit 1
428
  fi
429
  eval set -- "$arguments"
430

    
431
  # print welcome/info text if not suppressed
432
  if [[ $@ != *"--noinfo"* ]]; then
433
    printWelcomeText
434
  else
435
    printf "######################################################################\n"
436
  fi
437
  printf "\n"
438

    
439
  # set log file if specified
440
  if [[ $@ == *--log* || $@ == *--LOG* ]]; then
441
    # get the parameter (file name)
442
    local cmdidx=1
443
    while [ "${!cmdidx}" != "--log" ] && [ "${!cmdidx}" != "--LOG" ]; do
444
      cmdidx=$[cmdidx + 1]
445
    done
446
    local filenameidx=$[cmdidx + 1]
447
    # optionally force silent appending
448
    if [ "${!cmdidx}" == "--LOG" ]; then
449
      setLogFile --file="${!filenameidx}" --option=A
450
    else
451
      setLogFile --file="${!filenameidx}"
452
      printf "\n"
453
    fi
454
  fi
455

    
456
  # log script name
457
  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
458

    
459
  # if --help or -h was specified, print the help text and exit
460
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
461
    printHelp
462
    printf "\n"
463
    quitScript
464
  fi
465

    
466
  # handle command line arguments
467
  while [ true ]; do
468
    case $1 in
469
      --help|-h) # already handled; ignore
470
        shift 1;
471
        ;;
472
      --stm32flash|-f)
473
        stm32flashSetup; printf "\n"; shift 1
474
        ;;
475
      --SerialBoot|-s)
476
        serialBootSetup; printf "\n"; shift 1
477
        ;;
478
      --IDE|-e)
479
        IdeSetup; printf "\n"; shift 1;
480
        ;;
481
      --quit|-q)
482
        quitScript
483
        ;;
484
      --log|--LOG) # already handled; ignore
485
        shift 2
486
        ;;
487
      --noinfo) # already processed; ignore
488
        shift 1
489
        ;;
490
      --) # end of options reached
491
        shift; break
492
        ;;
493
      *) # sanity check (exit with error)
494
        printError "unexpected argument: $1\n"; exit -1
495
        ;;
496
    esac
497
  done
498

    
499
  # interactive menu
500
  while [ true ]; do
501
    # main menu info prompt and selection
502
    printInfo "AMiRo-BLT main menu\n"
503
    printf "Please select one of the following actions:\n"
504
    printf "  [F] - get and build stm32flash tool\n"
505
    printf "  [S] - build SerialBoot tool\n"
506
    printf "  [E] - IDE project setup\n"
507
    printf "  [Q] - quit this setup\n"
508
    readUserInput --num-chars=1 --options="FfSsEeQq" --out=userinput
509
    printf "\n"
510

    
511
    # evaluate user selection
512
    case $userinput in
513
      I|i)
514
        projectInitialization; printf "\n"
515
        ;;
516
      F|f)
517
        stm32flashSetup; printf "\n"
518
        ;;
519
      S|s)
520
        serialBootSetup; printf "\n"
521
        ;;
522
      E|e)
523
        ideSetup; printf "\n"
524
        ;;
525
      Q|q)
526
        quitScript
527
        ;;
528
      *) # sanity check (exit with error)
529
        printError "unexpected argument: $userinput\n"; exit -1
530
        ;;
531
    esac
532
  done
533

    
534
  exit 0
535
}
536

    
537
################################################################################
538
# SCRIPT ENTRY POINT                                                           #
539
################################################################################
540

    
541
main "$@"
542

    
543

    
544
## initial info text (can be disabled with 'no_info' as last argument)
545
#if [[ ! ${!#} = "no_info" ]]; then
546
#  printf "######################################################################\n"
547
#  printf "#                                                                    #\n"
548
#  printf "#                  Welcome to the AMiRo-BLT setup!                   #\n"
549
#  printf "#                                                                    #\n"
550
#  printf "######################################################################\n"
551
#  printf "#                                                                    #\n"
552
#  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
553
#  printf "#                                                                    #\n"
554
#  printf "# This is free software; see the source for copying conditions.      #\n"
555
#  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
556
#  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
557
#  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
558
#  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
559
#  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
560
#  printf "# Excellence Initiative.                                             #\n"
561
#  printf "#                                                                    #\n"
562
#  printf "######################################################################\n"
563
#  printf "\n"
564
#fi
565
#
566
## initialization of variables
567
#ARG_IDX=1
568
#USER_INPUT=${!ARG_IDX}
569
#
570
#while [[ ! $USER_INPUT =~ ^[Ee]$ ]]; do
571
#
572
#  # main menu info prompt and selection
573
#  printf "AMiRo-BLT setup\n"
574
#  printf "===============\n"
575
#  printf "\n"
576
#  if [[ -z $USER_INPUT || $USER_INPUT == "no_info" ]]; then
577
#    printf "Please select one of the following actions:\n"
578
#    printf "    [F] - stm32flash flashing tool setup\n"
579
#    printf "    [S] - SerialBoot flashing tool setup\n"
580
#    printf "    [Q] - setup QtCreator projects\n"
581
#    printf "    [E] - exit this setup\n"
582
#
583
#    while [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; do
584
#      read -p "your selection: " -n 1 -e USER_INPUT
585
#      if [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; then
586
#        printf "[%s] is no valid action. \n" $USER_INPUT
587
#      fi
588
#    done
589
#
590
#    printf "\n"
591
#    printf "######################################################################\n"
592
#    printf "\n"
593
#  fi
594
#
595
#  # action selection
596
#  case $USER_INPUT in
597
#
598
#    # stm32flash setup
599
#    F|f)
600
#      USER_DIR=${PWD}
601
#      cd $(dirname ${BASH_SOURCE[0]})
602
#
603
#      # initialize submodule
604
#      git submodule update --init ./Host/Source/stm32flash/
605
#
606
#      cd ./Host/Source/stm32flash/
607
#      BUILD_STM32FLASH=true
608
#
609
#      # test for existing bonary
610
#      if [ -f stm32flash ]; then
611
#        printf "WARNING: stm32flash binary already exists.\n"
612
#        read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT
613
#        if [[ $USER_INPUT =~ ^[Yy]$ ]]; then
614
#          BUILD_STM32FLASH=true
615
#          make clean
616
#        elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then
617
#          BUILD_STM32FLASH=false
618
#          printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT
619
#        else
620
#          BUILD_STM32FLASH=false
621
#        fi
622
#     fi
623
#
624
#      # build the tool if required
625
#      if [ $BUILD_STM32FLASH = true ]; then
626
#       make
627
#      fi
628
#
629
#      cd $USER_DIR
630
#      ;;
631
#
632
#    # SerailBoot setup
633
#    S|s)
634
#      # print setup header
635
#      printf "SerialBoot setup\n"
636
#      printf "================\n"
637
#      printf "\n"
638
#
639
#      USER_DIR=${PWD}
640
#      cd $(dirname ${BASH_SOURCE[0]})/Host/Source/SerialBoot/
641
#      BUILD_SERIALBOOT=true
642
#
643
#      # test for existing binary
644
#      if [ -f build/SerialBoot ]; then
645
#        printf "WARNING: SerialBoot binary already exists.\n"
646
#        read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT
647
#        if [[ $USER_INPUT =~ ^[Yy]$ ]]; then
648
#          BUILD_SERIALBOOT=true
649
#          rm -rf build/
650
#        elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then
651
#          BUILD_SERIALBOOT=false
652
#          printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT
653
#        else
654
#          BUILD_SERIALBOOT=false
655
#        fi
656
#      fi
657
#
658
#      # build the tool if requested
659
#      if [ $BUILD_SERIALBOOT = true ]; then
660
#        mkdir build
661
#        cd build
662
#        cmake ..
663
#        make
664
#      fi
665
#
666
#      cd $USER_DIR
667
#      ;;
668
#
669
#    # QtCreator setup
670
#    Q|q)
671
#      # calling the script with no arguments prints the help and returns
672
#      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh no_info
673
#      printf "\n"
674
#      # set deafult arguments and call the script again
675
#      USER_INPUT="clean all"
676
#      read -p "select commands: " -i "$USER_INPUT" -e USER_INPUT
677
#      printf "\n"
678
#      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh no_info $USER_INPUT
679
#      ;;
680
#
681
#    # exit
682
#    E|e)
683
#      break;
684
#      ;;
685
#
686
#    # sanity check
687
#    *)
688
#      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
689
#      printf "ERROR (${LINENO}): unexpected state; aborting script\n"
690
#      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
691
#      printf "\n"
692
#      exit
693
#      ;;
694
#
695
#  esac
696
#
697
#  printf "\n"
698
#  printf "######################################################################\n"
699
#  printf "\n"
700
#
701
#  let ARG_IDX++
702
#  USER_INPUT=${!ARG_IDX}
703
#
704
#done
705