cp bug?

Denys Vlasenko vda.linux at googlemail.com
Fri Mar 28 15:45:42 UTC 2008


On Friday 28 March 2008 16:22, Joakim Tjernlund wrote:
> 
> On Fri, 2008-03-28 at 09:44 -0500, Kevin Holland wrote:
> > You have to use something like 
> > cat myfile > /dev/mtdblock/1
> > because you don't have a filesystem mounted to that mtdblock I'm
> > assuming.  If there is a filesystem you would mount it then copy the
> > file to the mountpoint.
> > Kevin
> 
> Yeah, I know the cat trick works but so should cp too, I think. Earlier
> I used GNU cp and that worked like that. Compare with symlinks, cp
> copies the contents, not the symlink itself(unless -d or -P is given)

Well, GNU cp also copies TO dest symlink's target too,
which is incredibly careless. Hell knows where that symlink points -
/etc/passwd? /dev/sda? Cool, eh?

Instead of wanting cp to be a mix of copy and cat, why don't you use
cat when you want to say "please open and read from this file/device/pipe"?
That would be unambiguous. (Same holds for writing TO things - use >file).

As it stands now, cp's code is already a maze of heuristics
"what user actually wants, dammit?"
--
vda



More information about the busybox mailing list