Skip to contentSkip to conversation

cp: incorrect behaviour when copying recursively

DISCUSSION Peter Mamonov 2 participants 3 messages Apr 14, 2017 – Apr 21, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

The "cp -r <src> <dst>" command omits top directory, when the trailing "/" is present in the <src> string. Here is the test case:

barebox@barebox sandbox:/test mkdir d1 barebox@barebox sandbox:/test echo -o d1/f1 1 barebox@barebox sandbox:/test mkdir d2 barebox@barebox sandbox:/test cd d2 barebox@barebox sandbox:/test/d2 cp -r ../d1/ . barebox@barebox sandbox:/test/d2 ls
. .. f1
barebox@barebox sandbox:/test/d2 cp -r ../d1 . barebox@barebox sandbox:/test/d2 ls
. .. d1 f1

barebox@barebox sandbox:/test/d2 version

barebox 2017.04.0-00169-g90e7a35e6 #1 Fri Apr 14 12:46:09 MSK 2017

Regards,
Peter

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

Hi Peter,

Quoted 4 lines · Peter Mamonov

Hi,

The "cp -r <src> <dst>" command omits top directory, when the trailing "/" is present in the <src> string. Here is the test case:

I can confirm that. It turned out this is because we used GNU basename in barebox, but we should use POSIX basename. Please check the series I just sent out.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hi Sasha,

Quoted 11 lines · Sascha Hauer

Hi Peter,

Quoted 4 lines · Peter Mamonov

Hi,

The "cp -r <src> <dst>" command omits top directory, when the trailing "/" is present in the <src> string. Here is the test case:

I can confirm that. It turned out this is because we used GNU basename in barebox, but we should use POSIX basename. Please check the series I just sent out.

Tested the next branch: everything works as expected.

Thanks!
Peter

Quoted 8 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox