Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp --parents broken #165

Closed
dlegaultbbry opened this issue Jan 13, 2020 · 11 comments
Closed

cp --parents broken #165

dlegaultbbry opened this issue Jan 13, 2020 · 11 comments

Comments

@dlegaultbbry
Copy link

I tried this option and I found that it didn't behave like I think it should. It also doesn't have a test case for it.

mkdir -p 1/2/3
touch 1/2/3/blah
mkdir 4
./toybox cp -D 1/2/3/blah 4/
ctree -F 4/
4/
`-- 1/
    `-- 2/
        `-- 3

2 directories, 1 file

I expected the file 'blah' to be created at the end of 3, but it's actually the last directory portion which is created as the file '3'.

@jmakip
Copy link
Contributor

jmakip commented Jan 26, 2020

Yes I tested quickly and can confirm --parents is broken.

In original commit 8fdd58a where feature was added. cp --parents will copy folders 1/2/ into 4 and create copy of file named as 3, which is incorrect comparing to GNU coreutils behavior...

Current master says
$> ./cp --parents a/b/c/file d
cp: Skipped dir 'd/a/b/c': No such file or directory
Which is incorrect also

@jmakip
Copy link
Contributor

jmakip commented Feb 23, 2020

http://lists.landley.net/pipermail/toybox-landley.net/2020-February/011470.html

Send patch to list around week ago. (Rob did not reply so incase gmail spam filter got me again reposting here. )

landley pushed a commit that referenced this issue Mar 8, 2020
add: test for -D
fix: b/c/d/FILE not copying into a/ with -D option

dirname() is not needed when handling FLAG(D) since filename under
src or dest should not be changed.

github.com//issues/165
@lulcat
Copy link

lulcat commented Feb 8, 2021

Hmm, I see. I think if one adds SOURCE between leading and dirs, under DEST, one will understand this. I thought
this would do something a la -D by install:
cp -D file some/path/which/doesnt/exist/yet would leave me with some/path/which/doesnt/exist/yet/file :)

which would be nice to have in any case ,) as upsteam, I can imagine time is an issue and so I will throw it on my own todo heap, and chances are by the time I have made a patch for that, it's 2034 and half of California is no more.

@landley
Copy link
Owner

landley commented Feb 9, 2021

I'm sorry, I didn't understand that. Can you give me an example? (Keeping in mind that -D is theoretically just a synonym for --parents because I like longopts to have a corresponding short opt, so it's trying to do the same behavior as debian's cp --parents?)

@lulcat
Copy link

lulcat commented Feb 10, 2021

Hi. Ye, sorry I just haven't used that before, the -D thing, and when I read the cp --help, I understood it as create parents under DEST rather than under SOURCE. I mean listed in the arguments that is.

So I was trying something like : cp file a/b/c/d/file , and thinking it would act as install -D (create leading directories under DEST).

Sorry about that, I am using your install and am in need of rewriting a lot of internal scripts which use the gnu? install -t option. I think maybe that is why I got a bit confused by the cp -D help message :) so anyway, I had install -D in mind when I read cp -D help, and to me it would be more clear thus, if the word SOURCE was where I suggested. However, seeing your response, it seems I just was mixing up things and nevermind the noise :)

@landley
Copy link
Owner

landley commented Feb 10, 2021

If somebody actually needs install -t I can probably add it. Doesn't look like that big a deal?

@enh-google
Copy link
Collaborator

issue #133 was an explicit request for -t (though without a motivating example). #149 was an attempt at implementing it, but it stalled in review.

@enh-google
Copy link
Collaborator

also... should this bug be closed? what's left to do here after e76aeac? it says "minimal fix" but doesn't explain what (if anything) is still to be fixed...

@landley
Copy link
Owner

landley commented Feb 10, 2021

Commit 3d5cb06

@landley landley closed this as completed Feb 10, 2021
@jmakip
Copy link
Contributor

jmakip commented Feb 11, 2021

also... should this bug be closed? what's left to do here after e76aeac? it says "minimal fix" but doesn't explain what (if anything) is still to be fixed...

Original issue is fixed. It says "minimal fix" because I originally send messy complicated patch to list and Rob hinted me perhaps there is better way. So e76aeac is more refined version.

@enh-google
Copy link
Collaborator

ah, thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants