[phobos] popen/pclose and bug 3157
Andrei Alexandrescu
andrei at erdani.com
Thu Sep 9 07:03:43 PDT 2010
I think we need one more function - shellQuote. That would help people
quote their arguments properly to avoid trouble with filenames
containing spaces etc.
I suspect on Unix in general it suffices to prepend and append a single
quote ' and to replace any single quotes with '"'"'. Thus,
It's wonderful
becomes
'It'"'"'s wonderful'
Oh, and one more thing - shouldn't we template some functions on the
string type?
Andrei
On 9/9/10 6:43 CDT, Lars Tandle Kyllingstad wrote:
> On Thu, 2010-09-09 at 01:22 -0700, Brad Roberts wrote:
>> On 9/9/2010 12:59 AM, Lars Tandle Kyllingstad wrote:
>>> On Wed, 2010-09-08 at 13:52 -0700, Brad Roberts wrote:
>>>> On Wed, 8 Sep 2010, Lars Tandle Kyllingstad wrote:
>>>>> On Wed, 2010-09-08 at 02:14 -0700, Brad Roberts wrote:
>>>>>> I know that a major rework of std.process is a work in progress. What's the
>>>>>> state of it? I have a need, right now, for being able to execute a command and
>>>>>> getting back both it's output and its exit code.. and it needs to work on all
>>>>>> platforms.
>>>>>
>>>>> The current status is that the POSIX version works, and has done so for
>>>>> a while. Its incorporation in Phobos, and development of the Windows
>>>>> implementation, has been blocked by a DMD bug which is now fixed in SVN.
>>>>>
>>>>> So I guess the next steps will be
>>>>> 1. Wait for next DMD release, which will contain aforementioned fix.
>>>>> 2. Finish up Windows version.
>>>>> 3. Code review and hopefully acceptance in time for following release.
>>>>> [ 4. Deprecation and subsequent death of File.popen(). ;) ]
>>>>>
>>>>> -Lars
>>>>
>>>> Would you point me to the docs for the new version?
>>>
>>>
>>> Sure:
>>>
>>> http://kyllingen.net/code/ltk/doc/process.html
>>>
>>> -Lars
>>>
>>
>> Thanks.. I like the looks of it. spawnProcess looks like exactly what I'd love
>> to have right now. :)
>>
>> I didn't read super closely, but some things that I noticed:
>>
>> In enum Redirect, you might want to change 'all' to 'allstd' or something. Also,
>> you might want to generally comment about what's done with fd's NOT in the 0..2
>> (inclusive) range.
>
> It is mentioned in the spawnProcess() docs -- see the 'Note' section.
>
>
>> You have such a rich set for spawnProcess that the omission of a form of
>> pipeProcess, pipeShell, execute, and shell that also takes an env array stands out.
>
> I did consider it, but for completeness that would mean not just one,
> but two more forms of pipeProcess() and execute(). Example:
>
> // Already there:
> execute(command)
> execute(exe, args)
>
> // Add these?
> execute(command, env)
> execute(exe, args, env)
>
> It just seemed a bit too much for what I believed to be a rare need. If
> there is a real need for this, though, I don't have any problems with
> adding it.
>
> -Lars
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
More information about the phobos
mailing list