logical american <[email protected]> writes:
>> dan...@krosp:~$ ls -ld '/tmp/foo bar'
>> ls: cannot access /tmp/foo bar: No such file or directory
>> dan...@krosp:~$ perl -e 'mkdir("/tmp/foo bar/baz quux", 0777) or die $!'
>> No such file or directory at -e line 1.
>> dan...@krosp:~$ mkdir /tmp/'foo bar'
>> dan...@krosp:~$ perl -e 'mkdir("/tmp/foo bar/baz quux", 0777) or die $!'
>> dan...@krosp:~$ ls -ld '/tmp/foo bar'{,/*}
>> drwxrwxr-x 3 daniel daniel 21 Oct 2 13:50 /tmp/foo bar
>> drwxrwxr-x 2 daniel daniel 6 Oct 2 13:50 /tmp/foo bar/baz quux
>>
>> mkdir(2) and mkdir(3) (and related tools like mkdirat) will only create the
>> specific target directory, not any part of the path, as was mentioned.
>>
>> Also, if that didn't work ... well, it would have been noticed. :)
>>
>>> http://linux.die.net/man/3/mkdir mkdir() only takes two parameters and I'm
>>> not sure how it handles spaces in the parameter #1.
>> The same way any path handling function under Unix / POSIX does: they are
>> treated exactly the same as any other legal character for a file naming
>> component, which is to say like any character except for NUL and '/'.
>
> Ironically mkdir -p does create a full path directory with multiple slashes,
> I am using it right now in a shell script program. But apparently mkdir()
> won't
Well, yeah. By, like, design and all. The '-p' argument asks the mkdir
software to split the path, and create any missing directories, so it can do
that.
So, if you want that behaviour you need to implement it yourself, or grab some
code to do it for you. Pretty much every higher level language in existence
has "make the whole path" implemented somewhere. :)
Regards,
Daniel
--
✣ Daniel Pittman ✉ [email protected] ☎ +61 401 155 707
♽ made with 100 percent post-consumer electrons
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug