home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / bash / bug / 575 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.3 KB  |  47 lines

  1. Newsgroups: gnu.bash.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!fct.unl.PT!spa
  3. From: spa@fct.unl.PT (Salvador Pinto Abreu)
  4. Subject: odd `shift' behaviour with bash-1.12
  5. Message-ID: <SPA.92Aug27153635@khore-dump.fct.unl.pt>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Universidade Nova de Lisboa -- Lisbon, Portugal
  8. Distribution: gnu
  9. Date: Thu, 27 Aug 1992 14:36:50 GMT
  10. Approved: bug-bash@prep.ai.mit.edu
  11. Lines: 34
  12.  
  13. The scope of the `shift' command seems to be the innermost loop. For
  14. example, the following code:
  15.  
  16.         MAX_PARALLEL=...
  17.         MAX_PARALLEL_COUNT=$(echo -n $MAX_PARALLEL | wc -c)
  18.  
  19.         function bug {
  20.           local PARALLEL
  21.  
  22.           while [ -n "$1" ]; do
  23.             PARALLEL=$MAX_PARALLEL
  24.             echo 1>&2 bug: entering parallel loop.
  25.             while [ -n "$1" -a -n "$PARALLEL" ]; do
  26.               ( echo bug: output of $1 & )
  27.               PARALLEL=${PARALLEL#.}
  28.               shift
  29.             done | cat
  30.             [ -z "$LOOP" ] && shift $MAX_PARALLEL_COUNT
  31.           done
  32.         }
  33.  
  34.         bug 1 2 3 4 5 6 7 8    # runs fine
  35.         LOOP=on
  36.     bug 1 2 3 4 5 6 7 8    # loops
  37.  
  38. the second `shift' needs to be executed to shift the args to `bug',
  39. even though they were already (supposed to have been) kicked out by
  40. the `shift' in the inner loop.
  41.  
  42. bug or feature?
  43.  
  44. PS: tried on Ultrix 4.2, HP/UX A.B8.05 and NeXT Mach 2.2.
  45. --
  46.  
  47.