Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: commands sometimes don't execute (solved)

> Dave@xxxxxxxx wrote:
> > Did this get through?  Anyone know what's wrong?
> > Please reply to me directly, as I don't read the list.
> > I tried b10, and the problem is still there.
> I couldn't debug it with `jab' as it was so I changed it so that the
> first one printed called
> jab1() { print 1; }
> and the one in the until called
> jab0() { print 0; }
> and it seemed to work O.K.  If you don't believe this, or can find a
> simpler version of jab that shows the bug, I will try again.

Thanks for your help.  You made me look at it harder.
I made an even more exact simulation that allowed me
to vary some things until I saw what was really happening.

The problem was that the until loop was not being
entered at all.  The ping was succeeding on the first try,
but it took so long that the background message got printed.
For some silly reason, I assumed that this meant the until
loop must have been entered.

In case anyone wants this tool, or wants to
see this interesting shell programming example,
here's the corrected version:

# or maybe late model ksh

# Force a connection to the Internet over a demand-dial router
# Dave@xxxxxxxx 95-1-28 Works on SGI
# Dave@xxxxxxxx 95-7-18 Fixed the problem with printing the date.

# Parameters for the specific Internet Access Provider
provider_support_number="800 291 5178"


case "$1" in
-q) verbose= ;;
-r) repeating=yes ;;
"") ;;
*) echo 1>&2 "
Usage: internet [ -q ]

The -q option suppresses the usual verbose output.
" ;;

jab () {
    ping -qc 1 $ppphost | grep '1 packets received' > /dev/null
    echo $?

case "$verbose" in
yes) (sleep  2 ;
      echo "" > $tmp
      echo 1>&2 "Trying to call ${provider}...\c" ;
      sleep 30 ;
      echo 1>&2 ;
      echo 1>&2 "Trouble number is $provider_support_number" ;

if [[`jab` != 0]] ; then
    until [[`jab` = 0]] ; do
	case "$verbose" in
	    echo 1>&2 ".\c"

case "$verbose" in
yes) kill %%
     if test -r $tmp ; then
	rm -f $tmp
	echo 1>&2 ""
     echo 1>&2 Connected $when

Messages sorted by: Reverse Date, Date, Thread, Author