~ubuntu-branches/ubuntu/trusty/abs-guide/trusty-proposed

« back to all changes in this revision

Viewing changes to continue-nlevel.sh

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2012-06-03 10:57:27 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20120603105727-rm7frl4feikr2swm
Tags: 6.5-1
* New upstream release
* debian/watch
  - updated
* debian/abs-guide.lintian-overrides
  - updated for new upstream code
* debian/control
  - bump Standards-Version to 3.9.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# The "continue N" command, continuing at the Nth level loop.
 
3
 
 
4
for outer in I II III IV V           # outer loop
 
5
do
 
6
  echo; echo -n "Group $outer: "
 
7
 
 
8
  # --------------------------------------------------------------------
 
9
  for inner in 1 2 3 4 5 6 7 8 9 10  # inner loop
 
10
  do
 
11
 
 
12
    if [[ "$inner" -eq 7 && "$outer" = "III" ]]
 
13
    then
 
14
      continue 2  # Continue at loop on 2nd level, that is "outer loop".
 
15
                  # Replace above line with a simple "continue"
 
16
                  # to see normal loop behavior.
 
17
    fi  
 
18
 
 
19
    echo -n "$inner "  # 7 8 9 10 will not echo on "Group III."
 
20
  done  
 
21
  # --------------------------------------------------------------------
 
22
 
 
23
done
 
24
 
 
25
echo; echo
 
26
 
 
27
# Exercise:
 
28
# Come up with a meaningful use for "continue N" in a script.
 
29
 
 
30
exit 0