Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* word expansion and OSF libc
@ 1999-08-16  4:00 David T. Blake
  0 siblings, 0 replies; only message in thread
From: David T. Blake @ 1999-08-16  4:00 UTC (permalink / raw)


Hello,
	I wrote the following simple c program
********************
#include <wordexp.h>
#include <stdio.h>
main(){

        char foo[25];
        wordexp_t weout;
        int i,weflags = WRDE_NOCMD ;
                
        printf("Enter a string for me to expand: ");
        scanf("%s",foo);
        wordexp(foo,&weout,weflags);
        printf("%s %d matches \n",foo,weout.we_wordc);
        for (i=0;i<weout.we_wordc;i++){
                printf("%s \n",weout.we_wordv[i]);
        }
}
********************

As you might guess, it should take an argument from stdin,
and expand it as the shell would. This program, compiled
with cc -o foo -g foo.c
does what I would expect it to do. So far so good.

I embed the exact same function call in a larger program,
and it doesn't work. In fact, wordexp returns a zero return
value (no error) and does NO expansion.

So I attached dbx to the program, and apparently wordexp
in libc for Dec Unix 4.0D is exec'ing a shell. On closer
inspection, it appears to system a one line ksh script.
I find it very odd that a libc library call would call
a shell to perform its expansion - the other way around
seems more normal to me.

In any case, I am still stuck. The libc function call for
wordexp does NOT work in my larger program, and it doesn't
even fail properly (with a non-zero exit status). Is there
any recourse for building a cross-platform unix program that
uses a word expansion ?? Other than downloading the glibc 
code and building it myself, I mean.

-- 
Dave Blake
dblake@phy.ucsf.edu



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-08-16  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-08-16  4:00 word expansion and OSF libc David T. Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox