Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: dblake@popper.ucsf.edu (David T. Blake)
Subject: Re: wordexp (not Re: nanosleep ?)
Date: 1999/08/25	[thread overview]
Message-ID: <slrn7s8lnb.gg3.dblake@popper.ucsf.edu> (raw)
In-Reply-To: shemgrj1r8.fsf_-_@lnscu4.lns.cornell.edu

Daniel S. Riley <dsr@mail.lns.cornell.edu> wrote:
> dblake@popper.ucsf.edu (David T. Blake) writes:
> > So that if the environment is not what ksh wants, you get a return
> > value of zero. What do I need to do in my program to ensure that
> > the above ksh call works properly ?
> 
> Have you set WRDE_SHOWERR to see if anything prints to stderr?

Yes. It fails without error, which is exactly the problem.

 
> > On a second note, it is pretty messed up to have your C library 
> > functions rely on ksh expansions. It really ought to go the other
> > way.
> 
> POSIX Std 1003.2-1992, section E.9.9 (Rationale and Notes):
> 
>   While wordexp() could be implemented entirely as a library routine,
>   it is expected that most implimentations will run a shell in a
>   subprocess to do the expansion.
> 
> wordexp() is not even close to what I would consdider a core C
> library routine, sh and ksh predate wordexp() considerably, and,
> given all the weird parsing they do, getting wordexp() into a
> form actually usable by the various shells would be next to
> impossible. In context, forking a shell to do shell word
> expansion is a reasonable implimentation, as the POSIX committee
> acknowledged.

sh and ksh HAVE to implement the routine in C anyway, or in
whatever language used to contruct them. The GNU C library has a
full implementation of the word expansion, and does NOT fork a
system call to do globbing, tilde expansion, or variable
expansion. About the only thing you NEED the shell for is a
command expansion (ie: such as $(which .Xdefaults) in bash )
Besides, sh doesn't perform full word expansion anyway.

The issue really arises if ksh considers the environment from
which you call wordexp a restricted one, in which case ksh simply
does not do the expansion. That means the C library fails in a 
miserable and confused way leaving you without word expansion
at all, and no errors reported by the routine. 


-- 
Dave Blake
dblake@phy.ucsf.edu



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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-20  4:00 nanosleep ? Andreas Schnorr ATS/AT #47493
1999-08-20  4:00 ` linnartz
1999-08-23  4:00 ` Mark Koennecke
1999-08-23  4:00   ` Dave Butenhof
1999-08-23  4:00     ` David T. Blake
1999-08-25  4:00       ` wordexp (not Re: nanosleep ?) Daniel S. Riley
1999-08-25  4:00         ` David T. Blake [this message]
1999-08-25  4:00           ` David T. Blake
1999-08-26  4:00             ` Peter da Silva
1999-08-26  4:00               ` David T. Blake
1999-08-26  4:00                 ` Peter da Silva
1999-08-25  4:00       ` nanosleep ? Dave Butenhof
1999-08-25  4:00         ` David T. Blake
1999-08-24  4:00     ` Mark Koennecke
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