[lug] Fwd: Simple counter?

Anthony Foiani tkil at scrye.com
Sat May 25 12:12:00 MDT 2013

"Jeffrey S. Haemer" <jeffrey.haemer at gmail.com> writes:

> A shell one-liner would be an okay substitute: something
> intermediate between "echo $RANDOM" and "echo 9" . Â :-) (Thanks,
> Anthony.)

As someone upstream mentioned, the shell-level locking commands would
let us implement this in a few lines of shell, yes.  (Although you'd
want to spend extra attention to make sure that the lock got cleaned
up properly all the time, e.g., if someone hits ctrl+c after the lock
is taken but before it is freed up.)

> Sure, there are edge-cases, some not obscure: "If we call it a
> bunch, can't the numbers get awfully big?" But geez, ....

Heh.  I suspect this entire thread points out that the edge cases
(and, more generally, the *use* cases) make this a non-trivial
exercise.  Davide put it very well:

| If the "someone" wanted to make a general purpose solution, it would
| have been very complicated, as this discussion partially discussed.
| If "someone" wanted something for one specific reason, it would be
| so trivial that it would not have been worth the hassle of releasing
| it.  I believe that's why there isn't such a thing (as far as I'm
| aware and as far as everybody who has posted so far seem to be
| aware).

Happy hacking,

More information about the LUG mailing list