|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 > > >= 1993. But I'm not sure that the version string is guaranteed 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. > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 > >= 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? Try to ask in the ksh93-integration-discuss@opensolaris.org forum, David Korn himself answers questions there. > > Thanks. -- Wendy |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 >>= 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. 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/ |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
wendlin1974 wrote:
> whystopnow wrote: >> Is there a way to test in a script if the version of ksh is >= ksh93? > 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> |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Geoff Clare <ge...@clare.See-My-Signature.invalid> wrote:
> wendlin1974 wrote: > > whystopnow 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....bc8f9e5d362bf2 And, for completeness, a survey of various probes scripts, including the above: http://groups.google.com/group/comp....a0bcd47c5f2d6c 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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Geoff Clare wrote:
> wendlin1974 wrote: > > whystopnow wrote: > >> Is there a way to test in a script if the version of ksh is >= ksh93? > > > 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. 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 ![]() |
|
![]() |
| Outils de la discussion | |
|
|