Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: dblake@popper.ucsf.edu (David T. Blake)
Subject: word expansion and OSF libc
Date: 1999/08/16	[thread overview]
Message-ID: <slrn7rh8qq.qfa.dblake@popper.ucsf.edu> (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



                 reply	other threads:[~1999-08-16  4:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

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