zsh-users
 help / color / mirror / code / Atom feed
From: "Brian K. White" <brian@aljex.com>
To: <zsh-users@sunsite.dk>
Subject: Re: math, percentage
Date: Wed, 4 Jan 2006 23:43:54 -0500	[thread overview]
Message-ID: <00af01c611b2$a287fdb0$951fa8c0@venti> (raw)
In-Reply-To: <488030720601041505g7a9aee72nc8ebcf1bde13b3a4@mail.gmail.com>


----- Original Message ----- 
From: "John Reese" <john.reese@gmail.com>
To: "Brian K. White" <brian@aljex.com>
Sent: Wednesday, January 04, 2006 6:05 PM
Subject: Re: math, percentage


> Nice.
> Never knew you could do the assignment inside the braces like that,
> but even so I should have thought to at least try tp=$((t*100/T)) since I
> use n=$((n+1)) a hundred times a day.
>
> thanks
> Brian K. White  --  brian@aljex.com  --  http://www.aljex.com/bkw/

You could do
((n++))
instead and save three hundred characters a day.

----

Ah, neat. :)

It should be noted though:

Up to to this point the examples also work in ksh88 ,the version of ksh 
still shipping stock with many commercial unii as /bin/ksh.

((n++)) does not work in ksh88.
It does work in ksh93, bash, pdksh, and of course zsh.

Most of my fancier scripts need to explicitly call a particular shell anways 
because of special features, so this is useful.

Brian K. White  --  brian@aljex.com  --  http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro  BBx    Linux  SCO  FreeBSD    #callahans  Satriani  Filk!


-----
<off topic here but it should be explained why ksh93 doesn't obviate ksh88 
and thereby the portability comment>

The existence and availability of ksh93 for most platforms, even though it 
even ships stock with a few very recent ones (but still not as /bin/ksh), 
must not be considered as the simple answer for anything that doesn't work 
in ksh88 though because it's a bit buggy on some systems and cannot be used 
as the drop in replacement for the stock sh or ksh or as roots or even a 
users login shell. Ask me how I know. :) It seems ok at first but after a 
few days in production with a couple hundred users you realize you are 
having a lot of scattered problems you didn't used to have, and putting the 
old binary back ends the trend.

It's useful enough though to install it somewhere and call it explicitly on 
the bang line. My biggest item about ksh93 lately is that it has a built-in 
sleep that takes floating point values. I have things that really do want a 
"sleep .1", and anything that wants that, by definition also really wants it 
built-in, not to fork a child and load an executable every time. No other 
shell anywhere has that that I've found. (hint!)
Perl has nap() and probably other popular non bourne scripting languages 
have some form of usleep or sleep .xx but heck, so what? So does C.
Also there is:
    VARS="look at all these assignments woohoo read is cool how many lines 
of code would this be without it I ask you montoyo inigra"
    grep "^${LOGNAME}:" /path/to/userdefs | IFS=: read junk $VARS
    export $VARS
    echo $woohoo

The bugginess of ksh93 on the system above is at least partly due to the 
at&t build system for ksh that is such a pain in the ___ that hardly anyone 
even attempts to build it, and fewer succeed. For SCO Open Server 5.x.x and 
lower, there is exactly one binary out there, made by one guy a few years 
ago, and it's a little buggy, and he knew it all along, and he's not 
attempting to play with it again. I tried but ran into problems that I 
couldn't debug because the convoluted build system hid and buried the real 
problem too well and I actually have a job that doesn't allow me a couple of 
solid weeks just to build a new shell. :) So it's possible that ksh93 itself 
is fine and merely it's difficult to do a thorough job of porting it. Either 
way, it still means you can't count on it.


  parent reply	other threads:[~2006-01-05  4:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-31  6:56 Brian K. White
2005-12-31  7:22 ` Eric Mangold
2005-12-31  7:25 ` Dan Nelson
2005-12-31 20:44   ` Brian K. White
     [not found]     ` <488030720601041505g7a9aee72nc8ebcf1bde13b3a4@mail.gmail.com>
2006-01-05  4:43       ` Brian K. White [this message]
2006-01-05 23:54         ` Jonathan Hankins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00af01c611b2$a287fdb0$951fa8c0@venti' \
    --to=brian@aljex.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).