deprecation message std.process.system=>executeShell often not what's needed

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 12 23:28:59 PDT 2014


On Tue, Aug 12, 2014 at 11:09 PM, Lars T. Kyllingstad via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Tuesday, 12 August 2014 at 07:53:44 UTC, Timothee Cour via
> Digitalmars-d wrote:
>
>> The deprecation message in 2.066(rc): 'Deprecation: function
>> std.process.system is deprecated - Please use executeShell instead' is
>> often not what user wants.
>>
>
> Wait, what?  The pull request that deprecated system() was only merged a
> few days ago!  How can it already be in a release candidate?  I thought
> that once the beta cycle started only bug fixes would be incorporated.
>  Deprecations are breaking changes!
>

clarification: actually that was from git master, not from rc.


>
> But anyway, I agree that the deprecation message is somewhat off the mark.
>  The expression that most closely matches system(cmd) is
> wait(spawnShell(cmd)).
>
>
>  The behavior of the deprecated std.process should most closely be:
>>
>> int systemNew(in char[] args){
>> auto pipes = pipeShell(args, cast(Redirect)0);
>> return wait(pipes.pid);
>> }
>>
>> which could be a function in std.process if we deprecate
>> std.process.system
>> (possibly with a few extra parameters such as environment etc).
>>
>
> No, there is no point in using pipeShell() if you're not redirecting the
> streams.  Then you should use spawnShell().  pipeXyz() is just spawnXyz()
> plus automatic pipe creation.
>
> wait(spawnShell(cmd)) is simple enough that I don't think it needs to be a
> separate function in std.process.
>
>
>  Indeed, system doesn't capture output (which could potentially require
>> lots
>> of memory) [...]
>>
>
> Note that you can set executeShell's maxOutput parameter to zero, in which
> case it will not collect any output and thus not consume any memory.  But
> it still swallows the output, which you are right that system() does not.
>
> I will submit a pull request that changes the deprecation message.  Thanks
> for pointing it out!
>
> Lars
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140812/7b81e483/attachment.html>


More information about the Digitalmars-d mailing list