File: settrace.sh

package info (click to toggle)
zshdb 0.05%2Bgit20101031-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,104 kB
  • sloc: sh: 5,563; makefile: 337
file content (48 lines) | stat: -rwxr-xr-x 803 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env zsh
# Towers of Hanoi
set -u

init() {
  _Dbg_debugger; :
}

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

  _Dbg_debugger
  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 (( $# > 0 )) ; then
  top_builddir=$1
elif [[ -z ${top_builddir:-''} ]] ; then
  top_builddir=$PWD/../..
fi

if [[ -z ${top_srcdir:-''} ]] ; then
  top_srcdir=$PWD/../..
fi

if (( $# > 1 )); then
  cmdfile=$2
else
  srcdir=${top_srcdir:-'.'}
  cmdfile=${top_srcdir}/test/data/settrace.cmd
fi

source ${top_builddir}/dbg-trace.sh -q -L $top_builddir -B  -x $cmdfile
typeset -i max=1
init
hanoi $max 'a' 'b' 'c'
_Dbg_debugger 1 _Dbg_do_quit