Commit Graph

52 Commits

Author SHA1 Message Date
jkh
40570bdd13 UNIX conformance: If -r -f on non-existent directory, don't emit error. 2004-11-13 04:07:01 +00:00
delphij
ed0789bb33 Add -I, an option that asks for confirmation once if recursively
removing directories or if more than 3 files are listed in the
command line.

This feature is intended to provide a safe net but not being too
annoying like having "rm -i" for every deleting operations, and
is generally good for both newbies and power users, preventing
them from being so easily run into ``rm -rf /'', ``rm -rf *''
and so forth.

Originally implemented by Matthew Dillon for DragonFly, plus
some improvements done by various DragonFly contributors.

Approved by:	murray (mentor; the original dillon's version)
Discussed with:	des
Obtained from:	DragonFly's bin/rm/
		rm.c rev. 1.4 - 1.8
		rm.1 rev. 1.3 - 1.4
MFC After:	1 month
2004-10-28 08:25:30 +00:00
des
5741101d14 The previous commit added code to rm(1) to warn about and remove any
occurrences of "/" in the argument list.  This corresponds to Enhancement
Request Number 5 in the Austin Group TC2 Aardvark's XCU Defects Report
(<URL:http://www.opengroup.org/austin/aardvark/finaltext/xcubug.txt>).
Further discussion is available in the Austin Group mailing list archives
(<URL:http://www.opengroup.org/austin/mailarchives/>, "Defect in XCU rm")
and for Austin Group members, in the Austin Group Interpretations archive
(<URL:http://www.opengroup.org/austin/interps/>, AI-019)

This commit makes that check conditional on !POSIXLY_CORRECT, since it
is not strictly correct according to the current version of the standard
(but is expected to be correct according to the next version, and has
already been adopted by Solaris).
2004-10-04 19:24:28 +00:00
des
27d0a82356 Find out how flame-proof my underwear really is. 2004-10-04 11:26:01 +00:00
des
9171950fcb Whitespace cleanup. 2004-10-04 11:14:12 +00:00
markm
0336d895cd Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
kuriyama
6f984985c7 o Fix a style bug and poor wording in comment.
o When fts_read() cannot stat the file, it can't be unlinked.  At
  that case, don't display error message when -f flag is used.

Obtained from:	bde
PR:		kern/16815, bin/35842
Reported by:	kuriyama, Aleksandr A. Babaylov <.@babolo.ru>
2004-01-01 10:26:43 +00:00
guido
1f81441a73 When the P flag is set (i.e. Overwrite regular files before deleting them),
do only unlink the file if we could indeed overwrite the file.
Old behaviour: rm -P /tmp/foo (foo mode 0444) would NOT overwrite foo,
but still delete it (with a warning: rm: foo: Permission denied)
New behaviour: Just the EPERM warning, but no deletion

Reviewed by:	bde
2003-11-10 09:40:18 +00:00
bde
41e36ed57d 1. Fixed leakage of a file descriptor for every non-fatal failure in
rm_overwrite() (for rm -P).

2. Print the file name in the error message for (fatal) malloc() failures
   in rm_overwrite().  I first thought that malloc() failures should be
   non-fatal since they don't prevent proceeding the the next file, but
   making them non-fatal would normally give too much output for rm -Pr
   on a large tree in the unlikely event that even one occurs, since the
   malloc()ed amounts are usually the same.  Just print the file name since
   the malloc()ed amounts are not always the same and it doesn't hurt to
   know where rm was when it quit.

Submitted by:	guido ((1) and original version of (2))
2003-11-08 09:55:16 +00:00
obrien
8fbd9bc9e9 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
trhodes
76af16d03e s/filesystem/file system/ as discussed on -developers 2002-08-21 17:32:44 +00:00
tjr
d8d0133632 Complain if more than one file argument is given to unlink(1) like we did
before I made unlink use getopt().
2002-07-12 07:20:20 +00:00
dillon
75a17ac3b1 err() is documented as allowing NULL for the format string but GCC isn't
happy about it any more so change the usage to make buildworld work again.
2002-07-10 20:44:55 +00:00
obrien
3ba7184ea6 Consistently use FBSDID 2002-06-30 05:15:05 +00:00
tjr
b40f2151fc Reject options, handle "--" correctly in unlink(1). 2002-05-30 01:05:15 +00:00
trhodes
c496773415 Consistancy check s/file system/filesystem/
Reviewed by:	brian
2002-05-16 01:57:20 +00:00
imp
ebadb1bce0 Move user_from_uid to pwd.h
Move group_from_gid to grp.h
Remove from stdlib.h
Make the prototypes match the code
Fix rm and mv to include new files.

NetBSD has these defined in those files, and others too that I've not
done.

Approved by: terminal room kabal
Reviewed by: jhb, phk
2002-02-14 01:59:47 +00:00
imp
14c2daab0f o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
  they already are.
2002-02-02 06:48:10 +00:00
luigi
ba2942217c Add prototypes for main() so that these programs compile with -Werror
(which somehow now seems to be the default for compiling -current).
This error popped up while doing a PicoBSD cross-compile on a 4.3-ish system,
it may well be that there are other apps which have similar problems,
but I did not spot them as they are not included in my picobsd config.

Whether adding prototypes for main() is the correct solution or not
I have no idea, a request to -current on the matter went basically
unanswered. Those who have better ideas are welcome to back this out
and replace it with the correct fix.
2001-12-14 16:22:41 +00:00
ru
d5aca165c8 Removed wrong cast for fts_open()'s third argument. 2001-06-13 15:01:25 +00:00
obrien
5e2b5a5185 Display pathname of item being rm'ed.
Submitted by:	Peter Pentchev <roam@orbitel.bg>
2000-12-20 08:31:26 +00:00
joe
d38d9a6248 Switch over to using the new fflagstostr and strtofflags library calls. 2000-06-17 14:19:33 +00:00
asmodai
888d579612 Remove unused #include. 2000-05-01 18:34:36 +00:00
joe
bb1bbb6d1f Revert part of the last commit, remove {g|s}etflags from the libc
interface, and statically link them to the programs using them.
These functions, upon reflection and discussion, are too generically
named for a library interface with such specific functionality.
Also the api that they use, whilst ok for private use, isn't good
enough for a libc function.

Additionally there were complications with the build/install-world
process.  It depends heavily upon xinstall, which got broken by
the change in api, and caused bootstrap problems and general mayhem.

There is work in progress to address future problems that may be
caused by changes in install-chain tools, and better names for
{g|s}etflags can be derived when some future program requires them.
For now the code has been left in src/lib/libc/gen (it started off
in src/bin/ls).

It's important to provide library functions for manipulating file
flag strings if we ever want this interface to be adopted outside
of the source tree, but now isn't necessarily the right moment
with 4.0-release just around the corner.

Approved:	jkh
2000-02-05 18:42:36 +00:00
joe
a3a381812b Historically file flags (schg, uschg, etc) have been converted from
string to u_long and back using two functions, flags_to_string and
string_to_flags, which co-existed with 'ls'.  As time has progressed
more and more other tools have used these private functions to
manipulate the file flags.

Recently I moved these functions from /usr/src/bin/ls to libutil,
but after some discussion with bde it's been decided that they
really ought to go in libc.

There are two already existing libc functions for manipulating file
modes:  setmode and getmode.  In keeping with these flags_to_string
has been renamed getflags and string_to_flags to setflags.

The manual page could probably be improved upon ;)
2000-01-27 21:17:01 +00:00
sheldonh
a16eee301a Add link(1) and unlink(1) as special cases of ln(1) and rm(1)
respectively, in accordance with SUSv2.

This differs from the approach taken in NetBSD, but provides
less obscure error messages in at least the EISDIR case and
does not take up additional disk space for new binaries.

PR:		13071
PR:		13074
Requested by:	James Howard <howardjp@wam.umd.edu>
1999-12-20 16:13:47 +00:00
mharo
7e22d49a6b brucify
Reviewed by:	obrien
1999-11-28 09:34:21 +00:00
bde
45610c66ad Fixed longstanding breakage of rm of deep directories in rev.1.2.
rm must not use FTS_NOCHDIR, since chdir'ing is required for removing
deep directory trees and the ability to remove such trees is required
by POSIX.2 and POLA.  The breakage didn't make much difference until
recently, since fts(3) didn't work in deep directory trees.  It isn't
clear whether using FTS_NOCHDIR ever fixed anything (Net/2's rm.c is
similar to Lite1's).  Perhaps it was actually to limit the damage
caused by the fts bug.
1999-09-13 15:12:30 +00:00
mharo
281ecd6252 brucify, v' before W', mention -v is non-standard in manpage and
make code slightly easier to read

Reviewed by:	obrien
1999-09-04 03:40:10 +00:00
mharo
c6d21f8ff9 fix rm -r
Submitted by:	John Hay -- John.Hay@mikom.csir.co.za
1999-08-29 19:57:03 +00:00
mharo
7f61632b5b add verbose flag
exit(1) --> exit(EX_USAGE)

Reviewed by:	obrien
1999-08-29 02:20:26 +00:00
peter
3b7c52fb9a $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
kris
b2caa33057 Use .Dq instead of ``'' in manpage
Use optimal blocksize for rm -P, instead of always using 8192-byte blocks
to overwrite the file.

Obtained from:	OpenBSD
1999-05-28 12:47:31 +00:00
jkh
783145b62d Don't emit usage() message when no arguments given to -f. This
appears to be consistent with other Unixen, like Solaris.

PR:		10240
Submitted by:	jun_sun@hlla.is.tsukuba.ac.jp
1999-02-25 22:18:08 +00:00
steve
c3b9042311 Remove remaining Lite1 stuff from the man page and uphold the
precedence in changing sccsid to rcsid as set by Phillippe
Charnier in his previous 100 or so commits.

pointed out by: Bruce Evans <bde@zeta.org.au>
1997-08-07 21:37:39 +00:00
steve
1a8069828d Remove #if(n)def BSD_4_4_LITE cruft and change sccsid to rcsid. 1997-08-07 15:37:47 +00:00
dfr
c70c291f10 Enable whiteout code since we now have the lite2 support for them. 1997-04-29 10:03:10 +00:00
imp
cdc0e920d8 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-28 15:24:41 +00:00
peter
34fd560164 Revert $FreeBSD$ to $Id$ 1997-02-22 14:13:04 +00:00
jkh
9c0cd3f9df Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
steve
f36f15733f Merge Lite2 mods, and -Wall cleaning. Unimplemented undelete(2)
cruft is protected by a #ifdef (BSD4_4_LITE) that should be
removed when this is supported by the kernel.
1996-12-14 06:11:53 +00:00
wosch
fbfd06b398 fix usage string
respond `Y' is equal to `y'

Add a note how to delete file name with beginning `-'
1996-03-07 23:26:59 +00:00
pst
149ff31550 Don't initialize udata, fix usage string 1996-02-19 05:57:22 +00:00
wosch
2a9518f55e delete my last commit
Submitted by:	pst, ache
1996-02-19 00:44:19 +00:00
pst
0b55bfa8d9 Remove unnecessary '?' case and don't zero global udata, it's already zero 1996-02-18 19:54:04 +00:00
wosch
969d6e965c update usage string
all flag variables initialized with zero
respond `Y' is equal to `y'
1996-02-18 19:00:59 +00:00
ache
f1c135d401 Allow root to delete uchg/uappnd files 1995-04-13 13:35:09 +00:00
dg
00eb2a4dc0 Added $Id$ 1994-09-24 02:59:15 +00:00
bde
3c24b05a38 Remove redundant declarations that were added in the previous commit. 1994-09-21 22:31:01 +00:00
phk
b9caa52a52 Applied patch to make -Wall and -Dlint shut up.
Reviewed by:	phk
Submitted by:	Josef Grosch <joeg@gagme.wwa.com>
1994-09-20 07:18:04 +00:00