* Charles Steinkuehler ([EMAIL PROTECTED]) wrote:
> > I am going to try to do this.  I think I am mostly done.  Any advice on
> getting
> > rid of the "expr" commands that are doing math?
> 
> See the ash/bash man page.  You can do simple math with $(( )) expansion
> (add, sub, multiply, divide), although numbers are limited in range...ie:
> 
> echo "2 + 2 = $(( 2 + 2 ))"

Thanks.  I saw that in the man page just as I got your mail.  I have been
looking at more sh documentation.  It really doesn't pay to try to do these
things halfway, esp. with shell scripting.  Just more heartache.

The IFS/set solution you gave me works great, except for one unintended
consequence: it seems that everytime I run "test" on a file path, it parses the
path elements into separate args.

Let me just tell you a little about some hilarious shell scripting antics,
because anyone who has done this before will laugh.  I "solved" the problem
above by capturing the value of IFS into a variable called oldIFS so I could
use it later, then adding my delimiter like so:

oldIFS=$IFS
IFS="$IFS/"

I then proceeded to set IFS back to the old value after I got done, like so (thinking 
I had the problem licked):

IFS=oldIFS

Only to find that I still had my error.  Strangely, when I echo'ed the value of the 
path variable, it showed up like this:

 pr c/sys/net/ipv4/c nf/ipsec0/rp_fi ter

Whacky!

Of course, for any shell scripting newbies who might be reading this escapade
in the future from the archives, what is should have done is actually
dereference the variable in question, rather than set IFS to the sequence of
letters in the name of my variable!  Like this:

IFS=$oldIFS

Thanks, Charles.  I should be done in the next few days.

---------------------------------------------------------------------------
Chad Carr                                             [EMAIL PROTECTED] 
---------------------------------------------------------------------------

_______________________________________________
Leaf-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-user

Reply via email to