From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,2da5d5e41670269 X-Google-Attributes: gidfee84,public From: dblake@popper.ucsf.edu (David T. Blake) Subject: Re: wordexp (not Re: nanosleep ?) Date: 1999/08/25 Message-ID: #1/1 X-Deja-AN: 517177556 References: <37BCF41F.1EC5804D@de.ans.thomson-csf.com> <37C0ED14.9560FA43@psi.ch> <37C14023.B0712F05@compaq.com> Organization: UCSF, ITS User-Agent: slrn/0.9.5.4 (UNIX) Reply-To: dblake@phy.ucsf.edu Newsgroups: comp.unix.osf.osf1 Daniel S. Riley 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