File: settrace.sh

package info (click to toggle)
bashdb 3.1.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,252 kB
  • ctags: 117
  • sloc: sh: 4,880; pascal: 3,186; lisp: 484; makefile: 315; ansic: 294
file content (35 lines) | stat: -rwxr-xr-x 583 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Towers of Hanoi

init() {
  _Dbg_set_trace; : ; :
}

hanoi() { 
  local -i n=$1
  local -r a=$2
  local -r b=$3
  local -r c=$4

  _Dbg_set_trace; : ; :
  if (( n > 0 )) ; then
    (( n-- ))
    hanoi $n $a $c $b
    ((disc_num=max-n))
    echo "Move disk $n on $a to $b"
    if (( n > 0 )) ; then
       hanoi $n $c $b $a
    fi
  fi
}

if [[ -n $1 ]] ; then
  builddir=$1
elif [[ -z $builddir ]] ; then
  builddir=`pwd`/..
fi
source ${builddir}/bashdb-trace -q -L .. -B  -x settrace.cmd
typeset -i max=1
init
hanoi $max "a" "b" "c"
_Dbg_set_trace _Dbg_do_quit; : ; :