From: Loki Harfagr on
Sat, 14 Nov 2009 09:20:45 +0000, Seebs did cat :

> On 2009-11-14, Sidney Lambe <sidneylambe(a)nospam.invalid> wrote:
>> At the other end of the scale, you could write a complete desktop
>> environment in bash that functioned as well as KDE and used a tiny
>> fraction of the resources.
>
> That is a fascinating assertion. While I certainly think that KDE, et
> al., are pretty hugely bloated... It's hard for me to believe that a
> shell-based solution would be competitive. I don't know that I could be
> easily convinced that a shell-based window manager would be viable. Are
> there any?

Do you mean you don't yet know Sid's ODE?
Admitted, he still didn't publish the full env. but we'll be patient.
As Sid's father put it in the awards winning "Lambe's got a shell"
"/dev/null has a dignity of its own".
From: Seebs on
On 2009-11-14, Loki Harfagr <l0k1(a)thedarkdesign.free.fr.INVALID> wrote:
> Do you mean you don't yet know Sid's ODE?

Oh, it's okay, Sid said I could never talk to him again, I was just
asking the question of the newsgroup in general, because I think it's an
interesting one. I would be pretty sure that a shell would not be
able to compete effectively with even fairly inefficient C for something
like running a window manager.

-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Dominic Fandrey on
Sidney Lambe wrote:
> On comp.unix.shell, Dominic Fandrey <kamikaze(a)bsdforen.de> wrote:
>> Shell scripting often is a purpose of its own. It's really more
>> of an art form than real programming,
>
> I have been following this thread with interest and liked the
> way you handled the local gangsters.
>
> But the above statement of yours is ludicrous. Your OS wouldn't
> run without shell scripts and they are incredibly useful.
>
> ...

There is a slight distinction between often and always. ;)

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Dominic Fandrey on
Janis Papanagnou wrote:
> Dominic Fandrey wrote:
>> Janis Papanagnou wrote:
>>> Dominic Fandrey wrote:
>>>> I have written a framework for object oriented shell scripting.
>>>> It doesn't provide type safety or inheritance or access control,
>>>> but it has classes, objects and some other nice features like
>>>> automatic creation of getters and setters or return by reference.
>>> I think the getter and setter is the most unimportant feature in an
>>> object based approach. And all the Real OO Features are missing?
>>
>> To me inheritance and access control are only useful tools, not
>> necessary for the concept to work. Especially access control is
>> not required at all, it can completely be substituted with discipline.
>
> ...
>
>> Inheritance can be VERY useful, but often is not required at all.
>
> Well, YMMV, but OO just *starts* with inheritance; one of the few basic
> OO features is polymorphism, and inheritance is a precondition for that.

No it isn't. It only is a precondition if there is type safety.
Anyway, I added inheritance last weekend.

> ...
>
>> Do you
>> think it's possible to port Bourne Shell code or even write code
>> that works on both shells?
>
> Yes and no, depending on how your question is interpreted. Ksh is
> (as far as possible) an extension of Bourne shell (as is bash, for
> example), so quite all bourne shell programs should also work on ksh
> (or bash). Ksh also conforms to the POSIX standard. But, of course,
> backwards is not guaranteed; you cannot run a ksh program using e.g.
> the discipline function feature on a Bourne shell; Bourne shell is a
> more primitive predecessor.

The possibility of portability becomes less and less likely anyway.
One would probably have to branch it, even for a Linux system, simply
because of the tools FreeBSD offers that are not part of a common
GNU environment.

> One additional question resp. remark to your posted code; you are using
> the 'local' keyword, could it be that the freeBSD sh is actually a bash?
> You might get portability problems if you run your programs on a real sh
> in this case. Or is 'local' a keyword introduced and supported by your
> framework?

I only know what the manual page states:
HISTORY
A sh command, the Thompson shell, appeared in Version 1 AT&T UNIX. It
was superseded in Version 7 AT&T UNIX by the Bourne shell, which inher‐
ited the name sh.

This version of sh was rewritten in 1989 under the BSD license after the
Bourne shell from AT&T System V Release 4 UNIX.

It's definitely not a bash.

Regards

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Dominic Fandrey on
Maxwell Lol wrote:
> Ed Morton <mortonspam(a)gmail.com> writes:
>
>> And what newsgroup would it be where we respond to a comp.unix.shell
>> post about someone creating an object-oriented language in shell and
>> simply ask why they didn't just use an existing object-oriented
>> language if they wanted to do OOP?
>
> I think this is a fine newsgroup for the discussion.
>
> Of course there's a big difference between inventing a new OO language
> and inventing an object oriented language for interactive scripting,
> especially if it can be mixed with POSIX shell commands.
>

Interesting line of thought. /bin/sh on FreeBSD is nigh unusable as an
interactive shell, I'm using tcsh for that, which lacks some critical
features for scripting, but is nice for interactive use.
But based on a bash or somesuch shell this would be a fine use case.

> A OO shell might be useful on the command line. If, for example, one
> could pass objects between shell commands instead of text, and where
> one can mix objects with text. Think of somelike like an object
> oriented awk (which might be built into the shell):
>
>
> grep -v 'DEBUG' <file | encapsulate oclass |\
> ooawk '{ .func && .ip->print, .date->print}' |\
> oosort .date| decapsulate | lpr
>
>
> Where oclass is an object class definition that has
> function func
> date is a timestamp. perhaps from a log file
> ip is an IP address field

Some of that stuff is possible.

encapsulate would be a constructor that
reads from stdin, builds the data structure and at the end serializes
itself (which is a single command for the entire data structure) and
outputs its serialized self to stdout.

ooawk and oosort would have to work in a similar fashion, but really
you'd just call "$ooclass.sort .date" and "$ooclass.print". So all
that piping wouldn't be necessary.

Unfortunately you'd have to create a compatible deserialize function
for every language/tool you want object oriented interaction with.
It works much better the other way, objects using command line tools.

>
> ...
>
> We just had a case where people wanted to sort by dotted IP addresses.
> It should have it's specialized print function. And oosort would know
> how to sort an IP address, a time stamp, etc.

That doesn't sound difficult.

>
> I certainly don't want to use a language like Java for one- or
> two-line shell scripts. Buf if I could mix POSIX shell with OO stuff,
> that would be interesting.
>
> AIR, others have tried OO shells. I admit I never looked into these
> in detail, but google pointed me to:.
>
> http://geophile.com/osh/
> http://mediakey.dk/~cc/bash-shell-object-oriented/

I never looked at any of that. In deed it's the first time I become
aware. I wonder will following those links enlighten my path or spoil
me forever?
I better don't look before I am done.

> You know, I often have to use perl or shell to parse log files. If
> would be nice to have an object class that one can take any log file,
> and convert a text file into a consistent data structure, thst a small
> set of tools could operate one.

What would be possible is to have a collection of useful classes that
do things like parsing and reformatting log files and including it:
.. collection.sh

This way you could use these all the time.

Regards

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?