Hello All,
I seem to remember that KSH used to support the STDIO compatibility
library for built-in commands. Is this still so in the recent releases?
$ print -- $(.sh.version}
Version JMP 93u 2011-02-08
$ uname -a
SunOS rca 5.8 Generic_117350-33 sun4u sparc SUNW,Ultra-2 SunOS
$
I notice that there seems to be a problem with the STDIO compatibility
library for built-in commands. This problem (or deficiency) seemed to
be present in 2010 releases of KSH also.
I have the following built-in command (source code):
----------------
/* main (helloworld) */
#define CF_SFIO 0 /* use SFIO */
#include <shell.h>
#if SF_SFIO
#else
#include <stdio.h>
#endif
int b_helloworld(argc,argv,contextp)
int argc ;
char *argv[] ;
void *contextp ;
{
#if CF_SFIO
{
Sfio_t *fp = sfstdout ;
sfprintf(fp,"hello world!\n") ;
sfsync(fp) ;
}
#else
{
FILE *fp = stdout ;
fprintf(fp,"hello world!\n") ;
fflush(fp) ;
}
#endif /* CF_SFIO */
return 0 ;
}
/* end subroutine (b_helloworld) */
----------------
I make it with:
----------------
INCDIR=${AST}/include/ast
LIBDIR=${AST}/lib
LIBS="-lshell -last"
gcc -G -o libhw.so -I${INCDIR} helloworld.c -L${LIBDIR} ${LIBS}
----------------
I load it as:
$ builtin -f ${PWD}/libhw.so helloworld
When I run it straight out, I get:
$ whence -a helloworld
helloworld is a shell builtin
$ helloworld
hello world!
$
But when I run something like:
$ A=$( helloworld )
$ print -- ${A}
$
I get a blank line (not the proper output) when the built-in
command is compiled to use the STDIO compatibility library.
But if I recompile it to use the SFIO library, I get:
$ A=$( helloworld )
$ print -- ${A}
hello world!
$
As an aside, The same problem occurs on Sparc-Solaris-9:
$ uname -a
SunOS vinson 5.9 Generic_117171-09 sun4u sparc SUNW,Sun-Fire-880 SunOS
$
Has something or some support of the STDIO compatibility library for
built-in commands changed since a couple or few years ago? Have I done
something wrong in my source code (or build procedure) above?
Thanks for any feedback or information on this.
----
David Morano
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users