Repeat-by:
C
C bug.f
C
character*20 envvar
call getenv('AA',envvar)
write(6,10)envvar
10 format(1x,'Environment variable "AA"=',a)
stop
end
$ sh # use Bourne shell at first
$ f77 -o bug bug.f
bug.f:
MAIN:
$ AA=aa
$ export AA
$ AAA=bb
$ export AAA
$ env # note sorted environment
...
AA=aa
AAA=bb
...
$ bug
Environment variable "AA"=aa
$ ksh # now try it under Korn shell
$ env # note unsorted environment
...
AAA=bb
AA=aa
...
$ bug
Environment variable "AA"=
Fix:
In ye olde FORTRAN tradition, this fix involves adding a goto :-).
/usr/src/lib/libF77/getenv_.c:
...
if(*ep++ == '=') /* copy right hand side */
while( *ep && --vlen>=0 )
*value++ = *ep++;
else goto endloop; /* BUG FIX: if prefix match only,
continue the environment search */
goto blank;
endloop: ;
}
...
--
------------------------------- Disclaimer: The views contained herein are
| dan levy | yvel nad | my own and are not at all those of my em-
| an engihacker @ | ployer or the administrator of any computer
| at&t computer systems division | upon which I may hack.
| skokie, illinois |
-------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
go for it! allegra,ulysses,vax135}!ttrdc!levy