Hoi.

[2018-07-16 20:56] Vasilii Kolobkov <polezaivs...@ko5v.net>
> [2018-07-16 12:23 +0200] markus schnalke <mei...@marmaro.de>
> > [2018-07-15 23:29] Vasilii Kolobkov <polezaivs...@ko5v.net>
> > > 1. Generate sequences vi shell script as BSDs lack seq(1)
> > 
> > That's unfortunate, as seq(1) is such a great tool. It's not part
> > of POSIX though. (It originated in Research Unix after v7, i.e. on
> > the way to Plan 9 but after the SystemV and BSD have split off, IIRC.)
> 
> Yeah, read something like 'in Linux you do `seq 1 10` and in BSDs
> - `jot 10 1`'. Guess you got to learn to appreciate the fun bits
> like that, even if just to keep your nervous system intact when
> doing cross-platform stuff.

> Enough ground to keep a software anthropologist busy for a long
> while, heh? til, just keep interval expressions out of awk programms.

Yeah, an interesting topic in itself, this Unix history stuff.
I like it a lot. Of course, it makes portability a difficult job.
But, now that we have POSIX ... okay wait: eventually, when all
systems will implement it ... ;-P


> > Although $((...)) ist part of POSIX. I'd like to avoid it, if
> > possible. All uses of $((...)) in our test cases can be easily
> > converted to expr(1). Would that be okay for you or do do you have
> > strong opinions pro $((...))?
> 
> I hold no special feeling about arithmetic expressions in sh(1) -
> they do get clunky fast, but i still prefer shell constructs to
> involving some heavy hitters like awk. Mind sharing why you choose
> against them?

POSIX's goal was to document the common behavior across various
Unix derivates. In situations, when different, incompatible
behavior was present, it sometimes chose one of the alternatives
or none, if one could live without. For the most part, it refused
to standardize new behavior, especially if there was no important
reason to do so. To me, arithmetic expressions in sh are kind of
superfluous. There already exist alternatives in POSIX that are
older and more widespread: expr(1) for the simple stuff, bc(1)
for the complex stuff, test(1) for boolean, and awk(1) for the full
power of $((...)). Their only downside is time performance, which
I hardly like to accept as a good motivation.

Arithmetic expressions are an extension of the shell command
language, which introduces new syntax and a new thinking model,
whereas there already existed solutions, which either fitted
into the existing thinking model (expr(1), test(1)) or already
introduced new thinking models (bc(1), awk(1)).

IMO arithmetic expressions were unnecessary to add (from the Unix
standard shell POV (not from David Korn's POV, as I like to
admit)). (Even more, their syntax is badly chosen, as it is too
close to $(...) and (...).)

These are (conceptual) reasons I don't like arithmetic
expressions.

And, of course, old shells don't support them. Which is a
(increasingly less important) practical reason.


> The tr|sed|nl is such nice little gem i'd definitely go with it,
> readability objections well deserved still.

The coolnes factor is definitely high. ;-)

It's only acceptable if it is wrapped in a function with a name
that clearly describes what's going on.


> I'd rate the given options (in order of descending preference) -
> 1. tr|sed|nl 2. sh w/ expr(1) and 3. awk. What about you?

First step, I'd say: Write some enum() or countto() or even still
name it seq() function in test/common.sh, which only accepts a
single argument and does what seq(1) does if it has exactly one
argument. Then use this helper function in the test cases. The
actual implementation becomes a minor topic thus. We can change
it easily then.


> I believe it'll be best to keep this last patch as a draft and i'll
> keep adding more fixes to it.

Yes, keep going! Definitely worthwhile, your work!


meillo

Reply via email to