- return 0
- else
- o=$(get_path $p $end_point $start_point $((offset+1)))
- if [ $? -eq 0 ]; then
- if [ $shortest_path -eq -1 ] || [ $o -lt $shortest_path ]; then
- shortest_path=$o
+ if [ "$p" == "$end_point" ]; then
+ shortest_path=$offset
+ shortest_path_text="$path $p"
+ echo $((shortest_path - 1))
+ exit 0
+ else
+ o="$(get_path $p $end_point $start_point $((offset+1)) "$path $p")"
+ exit_code=$?
+ if [ $exit_code -eq 0 ]; then
+ if [ $shortest_path -eq -1 ] || [ $o -lt $shortest_path ]; then
+ shortest_path=$o
+ shortest_path_text="$path $p"
+ got_path=1
+ fi