Re: wordexp() implementation without fork()
Brian Inglis <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Organization | Systematic Software |
| Message-ID | <[email protected]> |
On 2020-08-05 11:09, Sebastian Huber wrote: > On 05/08/2020 17:35, Joel Sherrill wrote: >> Having a single process wordexp() implementation has been on the RTEMS >> POSIX wishlist for a while. I haven't been able to find one. The POSIX >> method description seems to hint that this implementation strategy is >> possible and the Linux man page uses the phrase "shell-like expansion". >> >> Does anyone know of an implementation that doesn't use fork()? Or an >> implementation strategy based around some open source wildcard evaluation? >> >> Or is this a POSIX method that is just unimplementable without multiple >> processes? > Can't you re-use parts of the shell implementation, e.g. freebsd_wordexpcmd() in > > https://github.com/freebsd/freebsd/blob/master/bin/sh/expand.c#L1507 The main issue seems to be if command substitution is supported, it has to be executed in a subshell, with the full capabilities of a POSIX shell: https://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html See RATIONALE: "While wordexp() could be implemented entirely as a library routine, it is expected that most implementations run a shell in a subprocess to do the expansion." -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in IEC units and prefixes, physical quantities in SI.]