I have the following script on AIX6.1 machine.
(13:43:27) c89f8v08:/tmp # oslevel -s
6100-04-00-0000
(13:45:34) c89f8v08:/ # cat /tmp/printVersionSeconds
#!/u/tmp/vut/ksh/ksh_aix_RISC.20120307
print .sh.version = ${.sh.version}
print KSH_VERSION = $KSH_VERSION
print SECONDS = $SECONDS
(13:46:01) c89f8v08:/ # /tmp/printVersionSeconds
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 49570.001
So far everything is ok. I have another script that call the above within perl
(13:47:24) c89f8v08:/ # cat /tmp/invokeFromNewerShell
#!/u/tmp/vut/ksh/ksh_aix_RISC.20120307
set -x
perl -e '$myout = `/tmp/printVersionSeconds `; print "$myout\n";'
print "#########################################"
perl -e '$myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";'
(13:47:26) c89f8v08:/ # /tmp/invokeFromNewerShell
+ perl -e '$myout = `/tmp/printVersionSeconds `; print "$myout\n";'
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 49651.242
+ print '#########################################'
#########################################
+ perl -e '$myout = `/tmp/printVersionSeconds 2>/dev/null`; print
"$myout\n";' <<=========== Stderr is redirected to /dev/null
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS =
49651
<<=========== An integer; this is not expected.
(13:47:41) c89f8v08:/ # locale
LANG=C
LC_COLLATE="C"
LC_CTYPE="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_MESSAGES="C"
LC_ALL=
If the grandparent/parent process is invoked from a another ksh version, the
result is not the same.
# Version M-11/16/88f
(14:15:51) c89f8v08:/ # cat /tmp/invokeFromOSshell
#!/usr/bin/ksh
set -x
perl -e '$myout = `/tmp/printVersionSeconds `; print "$myout\n";'
print "#########################################"
perl -e '$myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";'
(14:16:08) c89f8v08:/ # /tmp/invokeFromOSshell
+ perl -e $myout = `/tmp/printVersionSeconds `; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51371.001
+ print #########################################
#########################################
+ perl -e $myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51371.001
It looks like the SECONDS value type (integer or float) is depending on the
login shell too. I tried to play with this and get different result.
For example:
(14:24:07) c89f8sq04:/ # rsh c89f8v08
*******************************************************************************
* *
* *
* Welcome to AIX Version 6.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
Last login: Wed May 23 14:18:30 2012 on /dev/pts/1 from c89f8v80
(14:24:11) c89f8v08:/ # Version M-11/16/88f
(14:24:15) c89f8v08:/ # grep root /etc/passwd
root:!:0:0::/:/usr/bin/ksh
(14:24:26) c89f8v08:/ # /tmp/invokeFromNewerShell
+ perl -e '$myout = `/tmp/printVersionSeconds `; print "$myout\n";'
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51888.001
+ print '#########################################'
#########################################
+ perl -e '$myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";'
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51888
(14:24:48) c89f8v08:/ # /tmp/invokeFromOSshell
+ perl -e $myout = `/tmp/printVersionSeconds `; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51906.001
+ print #########################################
#########################################
+ perl -e $myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51906.001
Change to the new shell
(14:25:06) c89f8v08:/ # /u/tmp/vut/ksh/ksh_aix_RISC.20120307
(14:25:39) c89f8v08:/ # Version JM 93u 2011-02-08
(14:25:46) c89f8v08:/ # /tmp/invokeFromNewerShell
+ perl -e '$myout = `/tmp/printVersionSeconds `; print "$myout\n";'
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51952.984
+ print '#########################################'
#########################################
+ perl -e '$myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";'
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51953
(14:25:53) c89f8v08:/ # /tmp/invokeFromOSshell
+ perl -e $myout = `/tmp/printVersionSeconds `; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51960
+ print #########################################
#########################################
+ perl -e $myout = `/tmp/printVersionSeconds 2>/dev/null`; print "$myout\n";
.sh.version = Version JM 93u 2011-02-08
KSH_VERSION = Version JM 93u 2011-02-08
SECONDS = 51960
Here, the SECONDS are in integer in both cases (with or without the redirect)
I only see this issue on AIX (may be the default shell on AIX is ksh88?). And
I can only reproduce this with the help perl. I'm not sure if this affects any
other system variables. Please take a look.
Thanks,
Tru._______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers