Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jul 2006 12:28:35 +0200
From:      "no@spam@mgedv.net" <nospam@mgedv.net>
To:        <freebsd-questions@freebsd.org>
Subject:   RE: shell scripting: help appreciated
Message-ID:  <003901c69f54$9b954c80$01010101@avalon.lan>
In-Reply-To: <20060703174949.GA16998@holestein.holy.cow>

next in thread | previous in thread | raw e-mail | index | archive | help
> -----Original Message-----
> From: owner-freebsd-questions@freebsd.org 
> [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of Parv
> Sent: Monday, July 03, 2006 7:50 PM
> To: no@spam@mgedv.net
> Cc: freebsd-questions@freebsd.org
> Subject: Re: shell scripting: help appreciated
> 
> in message <006701c69e7a$7898db00$01010101@avalon.lan>,
> wrote no@spam@mgedv.net thusly...
> >
> > /bin/sh stops working correctly with a content-controlled do-loop.
> > 
> > the shell-script layout is as follows:
> > (it's not that trivial, just to show the meaning)
> > ---------------------------------------------------------------
> > /test/foo.conf (originally ~60 lines):
> > test1         testval1                optional_testval1
> > test2         testval2                optional_testval2
> > 
> > /test/foo.sh (this is the original loop code):
> > cat "$g_dir_etc/compile.lst"|\
> ...
> ( some pipeline )
> ...
> > while read gh_name gh_src gh_srcdir
> > do
> >       <set some vars here>
> >       /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1;
> >       <do some stuff here>
> > done;
> > 
> > /test/foo_sub.sh:
> > <we do very much stuff in here, like compiling programs etc...>
> > ---------------------------------------------------------------
> > 
> > if i change the line
> >       /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1;
> > to
> >       echo /bin/sh -c subprogram.sh $h_val1 $h_val2 $h_opt1;
> > the program loops for all records in the foo.conf correctly.
> > 
> > if i remove the "echo" keyword, the sub-script get's executed,
> > but the shell terminates as if there were lesser records in
> > the foo.conf file!
> > i scripted as many debug messages as possible, for every loop
> > they get executed and there are no errors/etc... happening.
> > and interestingly, the execution stops always on the same record!
> > if i comment out some records of my foo.conf, the sub-shell gets
> > executed for more records.
> 
> So, what is it exactly in the records (and/or values given to
> subprogram.sh) where the execution stops?
> 

it's not depending on the record. the layout of each record is 2
fixed an one variable field of data which is then put together to
directory/file-names inside the subprogram.
the subprogram just simply should loop for each record inside the
controlfile, which is done correctly if i change the subprogram to
an just "say hello" script.
if i run the really program, the loop stops (not immediately after
calling the subprogram, it just normal finishes the loop) after
working on lesser records as there are inside the .conf file.

no idea of what's going on.

btw., for each record - after the subprogram has successfully worked
on it a "done" flag is set and the subprogram is not called again
for this record.
looping the main program again and again renders the subprogram to
get executed for the other records as well.
it looks like, if there is heavy execution inside the subprogram,
the main program "forgets" about some data inside the loop.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003901c69f54$9b954c80$01010101>