From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Cox Subject: Re: Cleaning up elkscmd and adding help text - Questions Date: Fri, 27 Mar 2015 13:54:46 +0000 Message-ID: <20150327135446.61a7bca1@www.etchedpixels.co.uk> References: <551512AC.5050704@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <551512AC.5050704@gmail.com> Sender: linux-8086-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Nils Stec Cc: ELKS On Fri, 27 Mar 2015 09:19:56 +0100 Nils Stec wrote: > Hi, > > i started to write some patches, at the moment 2. Now it's the time to > ask you guys some questions about that. > > I wrote a patch for cat which shows the user some usage-information. > Jody Bruchon used write() for this purpose, other tools are using > fprintf(stderr, ....). > I don't know which i should prefer. In my opinion i would rather use > fprintf. > STDERR should be the output for operations, right? A lot of small programs try and avoid using stdio as it makes them a lot smaller in memory and on disk if they do so. > > I wrote a second patch, which adds some more functionality to cp. > It adds three command-line-options: > -v be verbose > -i be interactive, ask before overwriting > -n don't overwrite files > > i want to add 3 more options: > -u update-only (only overwrite if source is newer) > -b make a backup if destination file already exists > -f force, if destfile cannot be opened, remove it, try again. > > > Is this the right way to write code for this project? It's the first > time I'm doing this in here and i don't wan't to do things wrong... > > I think these two patches are still just drafts - i send them because i > want to show, i know theres more work to do on this two patches. They look ok to me, in fact the bug I see in patch #2 isn't yours - the existing code is not checking if the malloc of buf fails.... (and given its always needed it looks like it could just be declared as a fixed static buffer so that malloc isn't needed at all) Alan