system mkdir

Spacen Jasset spacenjasset at yahoo.co.uk
Fri Mar 19 16:54:29 PDT 2010


noboy wrote:
> There was a soft link /bin/sh -> dash
> I have change this to bash, and now all went fine.
> 
> Thank you
> 
> Steven Schveighoffer Wrote:
> 
>> On Thu, 18 Mar 2010 09:28:06 -0400, noboy <nobody at nowhere.com> wrote:
>>
>>> I was little bit surprise because
>>> mkdir -p dmd-2/usr/{bin,lib,src/phobos2,share/man
>>> do the right thing.
>> When you do that, you are using your shell.  The shell actually does the  
>> argument expansion, not mkdir.  So the question to answer is, does system  
>> use the shell or just call mkdir directly.  According to my man page,  
>> using system("cmd") is equivalent to doing /bin/sh -c cmd.  On my system  
>> doing this:
>>
>> /bin/sh -c 'mkdir -p /testdir/{a,b,c}'
>>
>> results in the desired behavior.  The single quotes force the shell I'm  
>> currently running *not* to expand the arguments, but pass them directly to  
>> /bin/sh as one string.  I would expect that system would execute the same  
>> command.
>>
>> I would guess on my system that your code would work properly, but I'm not  
>> sure.  What you need to find out is what /bin/sh actually is on your  
>> system.  Maybe it is a shell that does not understand how to expand the  
>> {a,b,c} term.  IIRC, /bin/sh usually is a link to bash, but I think on  
>> some systems, bash behaves differently if it's called via /bin/sh.
>>
>>> But if i make
>>> mkdir -p "dmd-2/usr/{bin,lib,src/phobos2,share/man"
>>> it's wrong.
>>>
>>> So i have think the system command wrap quotes about the command.
>> I don't think this is what's happening.
>>
>> -Steve
> 
then presumably the syntax you are using is a bashism?. You could also 
say something like:


system("bash mkdir -p " ~ path);


Messing with your sh symlink may have some undesired consequences.


More information about the Digitalmars-d-learn mailing list