[BusyBox] PATCH: cp /dev/null some_file

Anthony Shipman als at labyrinth.net.au
Sun May 30 16:55:56 UTC 2004


On Sun, 30 May 2004 11:08 pm, tom at ceisystems.com wrote:
> Anthony,
>
> > Below is a bug fix for the common idiom
> > 	cp /dev/null some_file
> > to create an empty file.
>
> I know this is getting a little off subject here, but what is the
> _correct_ thing to do when cp gets a device file for its source? Should
> it copy the dev file? I would think this would be the proper thing to
> do. What I'm getting at here is this- should we taint busybox with fixes
> for broken thinking? Isn't this what makes glibc and all of the standard
> tools so big?
>
> Thomas Cameron

Being able to cp from /dev/null is one of the things it is there for.
I hit this problem when installing postgresql using busybox as the
shell. The installation script was trying to create an empty file
as shown above.

What makes tools big is having special cases. The idea of devices
as files is to avoid special cases i.e. you can copy from any character
device the same way you can copy from any file e.g. with the cp command.

If you want to duplicate device files then have a command line flag to
specify this behaviour.
 
-- 
Anthony Shipman                    Elektrichore - The muse of 
als at labyrinth.net.au                          high technology.




More information about the busybox mailing list