Unix Shell - Testing for >= ksh93

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2007 > Testing for >= ksh93





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Testing for >= ksh93
whystopnow

2007-09-07, 1:20 am

Is there a way to test in a script if the version of ksh is >= ksh93?

I thought about examining ${.sh.version}, which is set to something
like "Version M 1993-12-28 s+". I could grep for 1993, but of course
someday when ksh200x comes out, that will fail.

I suppose I could parse out the year and test it as an integer to be
>= 1993. But I'm not sure that the version string is guaranteed to be

in that format.

I could I suppose try to use some ksh93-specific feature in an eval
and see if it works.

Any other ideas?

Thanks.

Janis Papanagnou

2007-09-07, 7:23 am

whystopnow wrote:
> Is there a way to test in a script if the version of ksh is >= ksh93?
>
> I thought about examining ${.sh.version}, which is set to something
> like "Version M 1993-12-28 s+". I could grep for 1993, but of course
> someday when ksh200x comes out, that will fail.


(I not yet see any ksh200x; they're still talking about fixing and
working on ksh93.)

> I suppose I could parse out the year and test it as an integer to be
>
>
> in that format.


I would indeed go that way. And since they are using an ISO standard
date schema you can be quite sure that there will be a YYYY-MM-DD
string in that variable.

> I could I suppose try to use some ksh93-specific feature in an eval
> and see if it works.


${.sh.version} is a ksh93-specific feature.

> Any other ideas?


In the first place I wouldn't check for 200x versions, because any
feature that is not yet deprecated would very likely be supported
by a ksh200x.

If you like to heavily restrict yourself you can also completely
avoid any features that are not defined in POSIX; that way you'll
gain a better portability (in any non-ancient Unix environments).

Janis

> Thanks.
>

wendlin1974@googlemail.com

2007-09-07, 7:23 am


whystopnow wrote:
> Is there a way to test in a script if the version of ksh is >= ksh93?
>
> I thought about examining ${.sh.version}, which is set to something
> like "Version M 1993-12-28 s+". I could grep for 1993, but of course
> someday when ksh200x comes out, that will fail.
>
> I suppose I could parse out the year and test it as an integer to be
> in that format.
>
> I could I suppose try to use some ksh93-specific feature in an eval
> and see if it works.
>
> Any other ideas?


Try to ask in the ksh93-integration-discuss@opensolaris.org forum,
David Korn himself answers questions there.

>
> Thanks.


--
Wendy

Richard T. Kus

2007-09-07, 1:32 pm

According to whystopnow <whystopnow@gmail.com>:
:Is there a way to test in a script if the version of ksh is >= ksh93?
:
:I thought about examining ${.sh.version}, which is set to something
:like "Version M 1993-12-28 s+". I could grep for 1993, but of course
:someday when ksh200x comes out, that will fail.
:
:I suppose I could parse out the year and test it as an integer to be
:>= 1993. But I'm not sure that the version string is guaranteed to be
:in that format.
:
:I could I suppose try to use some ksh93-specific feature in an eval
:and see if it works.
:
:Any other ideas?
:
:Thanks.
:

How about just check if .sh_version option. is valid; since ksh93 .sh_*
and not ksh88.

richk
John DuBois

2007-09-07, 7:36 pm

In article <1189142780.615531.244820@w3g2000hsg.googlegroups.com>,
whystopnow <whystopnow@gmail.com> wrote:
>Is there a way to test in a script if the version of ksh is >= ksh93?
>
>I thought about examining ${.sh.version}, which is set to something
>like "Version M 1993-12-28 s+". I could grep for 1993, but of course
>someday when ksh200x comes out, that will fail.
>
>I suppose I could parse out the year and test it as an integer to be
>in that format.
>
>I could I suppose try to use some ksh93-specific feature in an eval
>and see if it works.


Instead of testing for ksh93 in general, I usually test for the specific
features I actually *need*.

John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
Geoff Clare

2007-09-08, 7:31 am

wendlin1974 wrote:

> whystopnow wrote:
[vbcol=seagreen]
> Try to ask in the ksh93-integration-discuss@opensolaris.org forum,
> David Korn himself answers questions there.


That forum is not for general questions about ksh93. It is a place to
discuss issues related to the integration of ksh93 into OpenSolaris.

--
Geoff Clare <netnews@gclare.org.uk>
bsh

2007-09-11, 1:18 am

Geoff Clare <ge...@clare.See-My-Signature.invalid> wrote:
> wendlin1974 wrote:
> That forum is not for general questions about ksh93. It is a place to
> discuss issues related to the integration of ksh93 into OpenSolaris.


The "appropriate" forum is https://mailman.research.att.com/pipermail/ast-users/;
however, don't post there with a newby question or you
WILL get flamed. C.U.S. is better. And we're nicer, too

For a survey of past programmatic solutions, see:

http://groups.google.com/group/comp...0bc8f9e5d362bf2

And, for completeness, a survey of various probes scripts,
including the above:

http://groups.google.com/group/comp...ea0bcd47c5f2d6c

You should be aware that I have stopped developing whichshell,
in large part because of a recent interchange between Zdenek
Sekera and I. The canonical shells are both changing too fast,
and whose feature sets are converging to standards compliance,
making version discrimination problematic. Another modality
must now be pursued rather than detection of documented syntax
and exploitation of shell idioms.

The aforementioned advice given is probably sufficient. Try:

shver=` print -- ${.sh.version//!([0-9-])/} ` 2>/dev/null # not tested

It's too bad my function toolkit for version compliance is
not yet ready for distribution. It both emulates modern shell
functionality for older shells (like autoloading) as well as
providing a transparent abstraction layer to redirect autoloading
to the appropriate function version (that is, one for each shell),
plus a downward compatible function library for the "lowest
common denominator" of expected functionality written in
acceptably efficient code. Now _that_ would have been the
real solution....

=Brian

Roland Mainz

2007-09-25, 7:20 pm

Geoff Clare wrote:
> wendlin1974 wrote:
>
>
> That forum is not for general questions about ksh93. It is a place to
> discuss issues related to the integration of ksh93 into OpenSolaris.


Erm... IMO there is no problem with asking general-purpose questions in
that list[1] (however the more or less "official" ksh93 list is the
"ast-users" list (see
https://mailman.research.att.com/pipermail/ast-users/)) ...

[1]=(...and before someone starts to complain: I'm the list admin of the
ksh93-integration@opensolaris.org list...)

----

Bye,
Roland

--
__ . . __
(o.\ \/ /.o) roland.mainz@nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)
Roland Mainz

2007-09-26, 1:34 am

whystopnow wrote:
> Is there a way to test in a script if the version of ksh is >= ksh93?
>
> I thought about examining ${.sh.version}, which is set to something
> like "Version M 1993-12-28 s+". I could grep for 1993, but of course
> someday when ksh200x comes out, that will fail.


Erm, the current version is "ksh93s+" which means "korn shell based on
spec from 1993, version s+" (the "M" after the "Version" indicates that
the shell is compiled with multibyte support, e.g. it can handle
non-ASCII charatcers from languages like japanese/chinese/etc. if the
locale support this).

The "1993-12-28" can therefore be ignored for now since it's the same
since the initial ksh93 release and won't change in the forseeable
future, leaving the "s+" as the real version indicator.

[snip]
> Any other ideas?


On Solaris the following test works:
-- snip --
$ sh -c ' [ "`(echo ${.sh.version}) 2>/dev/null`" != "" ] && echo
"isksh93"'
$ ksh -c ' [ "`(echo ${.sh.version}) 2>/dev/null`" != "" ] && echo
"isksh93"'
$ ksh93 -c ' [ "`(echo ${.sh.version}) 2>/dev/null`" != "" ] && echo
"isksh93"'
isksh93
-- snip --
This works with the original Bourne shell, ksh88, ksh93 and bash...

----

Bye,
Roland

--
__ . . __
(o.\ \/ /.o) roland.mainz@nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com