Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"World domination. Fast" (By Linus Torvalds)


devel / comp.unix.shell / Re: Is ksh93 (or 2020) really better than bash?

SubjectAuthor
* Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93Kenny McCormack
+* Re: Is ksh93 (or 2020) really better than bash? (Was: awkJanis Papanagnou
|+- Re: Is ksh93 (or 2020) really better than bash? (Was: awkJanis Papanagnou
|`- Re: Is ksh93 (or 2020) really better than bash?Axel Reichert
`* Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in kJohn McCue
 `* Re: Is ksh93 (or 2020) really better than bash? (Was: awkChristian Weisgerber
  `* Re: Is ksh93 (or 2020) really better than bash?John McCue
   `- Re: Is ksh93 (or 2020) really better than bash?Kenny McCormack

1
Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)

<sumeft$jbo0$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4974&group=comp.unix.shell#4974

  copy link   Newsgroups: comp.lang.awk comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.awk,comp.unix.shell
Subject: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)
Date: Thu, 17 Feb 2022 21:25:17 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sumeft$jbo0$1@news.xmission.com>
References: <87fsohxmuc.fsf@axel-reichert.de>
Injection-Date: Thu, 17 Feb 2022 21:25:17 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="634624"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Thu, 17 Feb 2022 21:25 UTC

In article <87fsohxmuc.fsf@axel-reichert.de>,
Axel Reichert <mail@axel-reichert.de> wrote:
....
>While searching here and there on the web, I stumbled again across
>ksh93, which was advertised back then with
>
> The new version of ksh has the functionality of other scripting
> languages such as awk, icon, perl, rexx, and tcl. For this and many
> other reasons, ksh is a much better scripting language than any of the
> other popular shells.
>
>When I saw that it comes with floating point arithmetic, arrays (indexed
>and associative) the questions occured to me how true the rather bold
>claim quoted above is.

I wonder about that. I doubt I'd have to work very hard to come up with
something that I can do in GAWK that can't be done in ksh93.

But what I'm really wondering about is whether it makes sense to switch to
ksh from bash for my day-to-day shell scripting. I'm pretty familiar and
comfortable with bash at this point; I'd rather not switch unless there was
a good reason.

The system that I am typing on right now has /usr/bin/ksh as a link to
/usr/bin/ksh2020 - which is, presumably, 27 years better than ksh93 (if you
see what I mean...). I'd like to hear from people knowledgeable on both
shells as what kind of advantages ksh has over bash.

The one that I am aware of is floating point math handled natively in the
shell. This is a significant thing, and one I often miss in bash. I see
no particular reason why it could not be implemented in bash. In fact,
I've worked up a system where I run "bc" as a co-process that works pretty
well. Note that if you Google "floating point in bash", you'll get lots of
suggestions to use "bc", but none (AFAICT) mention running it as a
co-process. That seems to be my innovation.

--
Kenny, I'll ask you to stop using quotes of mine as taglines.

- Rick C Hodgin -

Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)

<sumip9$s24$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4975&group=comp.unix.shell#4975

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash? (Was: awk
functionality not in ksh93)
Date: Thu, 17 Feb 2022 23:38:32 +0100
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <sumip9$s24$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de>
<sumeft$jbo0$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Feb 2022 22:38:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d93e526db323c09bcacc88c6e3071c45";
logging-data="28740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18I8YDOaprKVLc/SyVNAxjk"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:YzFX/aE7ibn2Hun2uIvwmX1rSk4=
In-Reply-To: <sumeft$jbo0$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Thu, 17 Feb 2022 22:38 UTC

[ crosspost to CLA removed ]

On 17.02.2022 22:25, Kenny McCormack wrote:
> [...]
>
> But what I'm really wondering about is whether it makes sense to switch to
> ksh from bash for my day-to-day shell scripting. I'm pretty familiar and
> comfortable with bash at this point; I'd rather not switch unless there was
> a good reason.

My guess would be that it's not necessary if you don't mind the speed
degradation of bash and had not yet need for any of the advanced ksh93
features.

>
> The system that I am typing on right now has /usr/bin/ksh as a link to
> /usr/bin/ksh2020 - which is, presumably, 27 years better than ksh93

If I read what this 2020 thing actually is, I wouldn't bet on that.[*]
And also mind that version "ksh93u+" is from Aug 2012, quite "new".

What has to be said about the quasi-standard ksh93u+ is that it has a
couple nerving bugs in interactive use (that may be considered as being
irrelevant if used only for scripting). If you want to switch I'd surely
suggest to use the derived version ksh93u+m (see the announcement post
from Marijn Deckker, Dec 2021, in this newsgroup); this works flawless
it seems, the author seems to have spent a lot effort in bug-fixing.

> (if you
> see what I mean...). I'd like to hear from people knowledgeable on both
> shells as what kind of advantages ksh has over bash.

Speed, features, always leading inventor of useful new features.[**]

Enumerating the features is cumbersome, since bash was trying to catch
up over the time, and a feature missing in earlier bash releases might
now be part of it. Off the top of my head: FP-arithmetic and a lot of
the C-lib functions, arithmetic for-loop, arithmetic command, command
negation, more [[...]] tests, many variable expansion variants, a lot
of performant builtins, extended patterns are standard, IO-redirections
to seek and skip in files, scope in functions (visibility, signals,
getopts, ...), name references, so called discipline functions (that
can be associated with variables to trigger actions on read/write/...),
data type definitions, extended printf controls, support for shell and
regexp patterns, ANSI quoting, the extremely powerful getopts, and
certainly I forgot to mention many many more.

If you used in your scripts the few bash-specifics (that ksh typically
supports in another form) these programs may break (unless you use #!
mechanics).

One thing to also consider for a decision is that bash, as standard
shell and inherent part on Linux systems, will probably be continued,
while I don't know the plans for ksh93u+m (and AT&T's branch ksh93u+
is a dead end anyway, I suppose).

>
> The one that I am aware of is floating point math handled natively in the
> shell. This is a significant thing, and one I often miss in bash. I see
> no particular reason why it could not be implemented in bash.

Indeed. And I am wondering why over that long period of time it's
not yet been implemented in bash, since the syntactic context is
quite localized, mainly in $((...)), ((...)), and for((...)) loops.

> In fact,
> I've worked up a system where I run "bc" as a co-process that works pretty
> well. Note that if you Google "floating point in bash", you'll get lots of
> suggestions to use "bc", but none (AFAICT) mention running it as a
> co-process. That seems to be my innovation.

LOL. Think about it. In the early 1990's I used ksh88, which did
support co-processes already, but didn't support FP-arithmetic.
What do you think is the straightforward workaround for ksh-users
at that time? ;-)

Janis

[*] https://en.wikipedia.org/wiki/KornShell :
KornShell, i.e. ksh2020, a "major release for several reasons"
(such as removal of EBCDIC support, dropped support for binary
plugins written for ksh93u+ and removal of some broken math
functions), was released by AT&T, but is not maintained or
supported (by AT&T; wasn't even on release date).

[**] The latter isn't true any more since the labs fired the authors
and discontinued development. If you follow the ksh93u+m path it's a
different situation, though.

Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)

<sunui2$7o4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4976&group=comp.unix.shell#4976

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash? (Was: awk
functionality not in ksh93)
Date: Fri, 18 Feb 2022 12:05:37 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <sunui2$7o4$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de>
<sumeft$jbo0$1@news.xmission.com> <sumip9$s24$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Feb 2022 11:05:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0851dd9e8df0d6b2a27c6470d35d488b";
logging-data="7940"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ecRrHWxDDXtJSzSxke/PF"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6ROwnIlnOo26ALYeSgeDFAo/Wp0=
In-Reply-To: <sumip9$s24$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 18 Feb 2022 11:05 UTC

On 17.02.2022 23:38, Janis Papanagnou wrote:
> On 17.02.2022 22:25, Kenny McCormack wrote:
>> In fact,
>> I've worked up a system where I run "bc" as a co-process that works pretty
>> well. Note that if you Google "floating point in bash", you'll get lots of
>> suggestions to use "bc", but none (AFAICT) mention running it as a
>> co-process. That seems to be my innovation.
>
> LOL. Think about it. In the early 1990's I used ksh88, which did
> support co-processes already, but didn't support FP-arithmetic.
> What do you think is the straightforward workaround for ksh-users
> at that time? ;-)

BTW, I was astonished about your statement that Google had no entries.
so I searched Google Groups for this newsgroup and "co-process" and
stumbled across the post/reply I appended below, dated Aug 7, 2004.
It is probably not the first post on that topic and other folks have
certainly used that co-process principle in context with bc before
(as I did in the 1990's) without posting about it, but at least it
seems to stem from a time back when bash didn't support it.

Janis

--- quote begin ---

JQ wrote:
> Would someone be so kind as to explain coprocesses? I don't know if
> bash now supports them of if it's still in Korn's domain. I've never
> quite understood where to best make use and practice of them.

You may view them as providers for external services that are available
to your process.

Say you have some powerful external service like bc's multiple precision
integer arithmetic that you constantly want to use. Start the co-process
and whenever you have a calculation send a message to the coprocess and
get the answer.

You may also use it if you want to provide some new user interface to an
existing program. You take the user input, maybe manipulate the data,
then send it to the coprocess, get the response, optionally change/format
the output to your needs.

The syntax to use it, if not already known to you, is

bc |& # create coprocess 'bc'
while read query?"Enter your data: "
do
print -p "${query}" # send message to coprocess
read -p response # receive response from coprocess
done

My version of bash (2.05) seems to not support coprocesses, at least not
with the ksh syntax.

HTH

Janis

--- quote end ---

Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)

<suoeb6$pi5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4977&group=comp.unix.shell#4977

  copy link   Newsgroups: comp.lang.awk comp.unix.shell
Followup: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jmc...@magnetar.hsd1.ma.comcast.net (John McCue)
Newsgroups: comp.lang.awk,comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)
Followup-To: comp.unix.shell
Date: Fri, 18 Feb 2022 15:35:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <suoeb6$pi5$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumeft$jbo0$1@news.xmission.com>
Reply-To: jmclnx@SPAMisBADgmail.com
Injection-Date: Fri, 18 Feb 2022 15:35:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4535bd97640ac1e9e107aa3db3767464";
logging-data="26181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gC3DejdQ0NjUmHy/hUQ6j"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:hyKffKB7AC9Swn45ufsd3PV/wpQ=
X-OS-Version: Slackware 15.0 x86_64
 by: John McCue - Fri, 18 Feb 2022 15:35 UTC

trimmed followups to comp.lang.awk

In comp.unix.shell Kenny McCormack <gazelle@shell.xmission.com> wrote:
<snip>

> But what I'm really wondering about is whether it makes sense to switch to
> ksh from bash for my day-to-day shell scripting. I'm pretty familiar and
> comfortable with bash at this point; I'd rather not switch unless there was
> a good reason.

Depends, will you ever write scripts for any of the BSDs
or a proprietary UNIX ?

If so you may want to use ksh. Otherwise it does not
matter.

>
> The system that I am typing on right now has /usr/bin/ksh as a link to
> /usr/bin/ksh2020 - which is, presumably, 27 years better than ksh93 (if you
> see what I mean...). I'd like to hear from people knowledgeable on both
> shells as what kind of advantages ksh has over bash.

YYMV on that one, OpenBSD defaults to a ksh88 clone,
AIX defaults to ksh88. NetBSD seems to default to a ksh
look-alike and the same now seems to be true for FreeBSD.
>
> The one that I am aware of is floating point math handled natively in the
> shell. This is a significant thing, and one I often miss in bash. I see
> no particular reason why it could not be implemented in bash. In fact,
> I've worked up a system where I run "bc" as a co-process that works pretty
> well. Note that if you Google "floating point in bash", you'll get lots of
> suggestions to use "bc", but none (AFAICT) mention running it as a
> co-process. That seems to be my innovation.

I use bc(1) when I need floating point math since I write
shell scripts assuming ksh88.

--
[t]csh(1) - "An elegant shell, for a more... civilized age."
- Paraphrasing Star Wars

Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93)

<slrnt0vpeg.u7q.naddy@lorvorc.mips.inka.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4978&group=comp.unix.shell#4978

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash? (Was: awk
functionality not in ksh93)
Date: Fri, 18 Feb 2022 18:30:40 -0000 (UTC)
Message-ID: <slrnt0vpeg.u7q.naddy@lorvorc.mips.inka.de>
References: <87fsohxmuc.fsf@axel-reichert.de>
<sumeft$jbo0$1@news.xmission.com> <suoeb6$pi5$1@dont-email.me>
Injection-Date: Fri, 18 Feb 2022 18:30:40 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="30971"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Fri, 18 Feb 2022 18:30 UTC

On 2022-02-18, John McCue <jmccue@magnetar.hsd1.ma.comcast.net> wrote:

> Depends, will you ever write scripts for any of the BSDs
> or a proprietary UNIX ?
>
> If so you may want to use ksh.

POSIX sh is the much better bet there.

> YYMV on that one, OpenBSD defaults to a ksh88 clone,
> AIX defaults to ksh88. NetBSD seems to default to a ksh
> look-alike and the same now seems to be true for FreeBSD.

No, FreeBSD has a POSIX sh and does not ship with anything ksh-ish
out of the box.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Is ksh93 (or 2020) really better than bash?

<87zgmnwzva.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4979&group=comp.unix.shell#4979

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash?
Date: Fri, 18 Feb 2022 23:53:29 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <87zgmnwzva.fsf@axel-reichert.de>
References: <87fsohxmuc.fsf@axel-reichert.de>
<sumeft$jbo0$1@news.xmission.com> <sumip9$s24$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="5a7379fa6be24020eb8ac708bf01eed7";
logging-data="7834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18U06b/gtGZJiitN8g9lCLmAMtkvHRCD68="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:MLtwBohzfJaAJDT//BKzNRvC4Xo=
sha1:03NW+qLbP/BaqEDLShRv2be97MI=
 by: Axel Reichert - Fri, 18 Feb 2022 22:53 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> use the derived version ksh93u+m (see the announcement post from
> Marijn Deckker, Dec 2021, in this newsgroup)

.... which was also the one I had in mind when asking.

Axel

Re: Is ksh93 (or 2020) really better than bash?

<supkp2$nsn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4980&group=comp.unix.shell#4980

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jmc...@qball.Belkin (John McCue)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash?
Date: Sat, 19 Feb 2022 02:30:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <supkp2$nsn$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumeft$jbo0$1@news.xmission.com> <suoeb6$pi5$1@dont-email.me> <slrnt0vpeg.u7q.naddy@lorvorc.mips.inka.de>
Reply-To: jmclnx@SPAMisBADgmail.com
Injection-Date: Sat, 19 Feb 2022 02:30:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2ef547ee844e4745ae895a8343781ac3";
logging-data="24471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WYpSjlHSzgAp5IcmmPNJM"
User-Agent: tin/2.4.4-20191224 ("Millburn") (OpenBSD/7.0 (amd64))
Cancel-Lock: sha1:Wok8N0lBZyjZCMw+i2SlSXP22rI=
X-OS-Version: OpenBSD 7.0 amd64
 by: John McCue - Sat, 19 Feb 2022 02:30 UTC

Christian Weisgerber <naddy@mips.inka.de> wrote:
<snip>
> No, FreeBSD has a POSIX sh and does not ship with anything ksh-ish
> out of the box.

Was not sure about FreeBSD with its shell, good to know.

Re: Is ksh93 (or 2020) really better than bash?

<suq620$lg0q$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4981&group=comp.unix.shell#4981

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Is ksh93 (or 2020) really better than bash?
Date: Sat, 19 Feb 2022 07:25:52 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <suq620$lg0q$1@news.xmission.com>
References: <87fsohxmuc.fsf@axel-reichert.de> <suoeb6$pi5$1@dont-email.me> <slrnt0vpeg.u7q.naddy@lorvorc.mips.inka.de> <supkp2$nsn$1@dont-email.me>
Injection-Date: Sat, 19 Feb 2022 07:25:52 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="704538"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 19 Feb 2022 07:25 UTC

In article <supkp2$nsn$1@dont-email.me>,
John McCue <jmclnx@SPAMisBADgmail.com> wrote:
>Christian Weisgerber <naddy@mips.inka.de> wrote:
><snip>
>> No, FreeBSD has a POSIX sh and does not ship with anything ksh-ish
>> out of the box.
>
>Was not sure about FreeBSD with its shell, good to know.

It is hard to imagine a less relevant point in the context of the thread
topic.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Rorschach

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor