Commit Graph

124 Commits

Author SHA1 Message Date
Jordan K. Hubbard
de3abdfaf4 UNIX conformance: If -r -f on non-existent directory, don't emit error. 2004-11-13 04:07:01 +00:00
Xin LI
164d3f0bdc Correct a typo and make the documentation more mdoc(7) complaint.
Pointed out by:	dd
Approved by:	murray (mentor)
2004-11-01 16:52:34 +00:00
Xin LI
24c0f7385b 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
Dag-Erling Smørgrav
3f91ab9262 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
Dag-Erling Smørgrav
3a667dafcc Markup fixes.
Pointed out by:	ru
2004-10-04 19:03:44 +00:00
Dag-Erling Smørgrav
68ef5f71b0 Find out how flame-proof my underwear really is. 2004-10-04 11:26:01 +00:00
Dag-Erling Smørgrav
c335b1ecdb Whitespace cleanup. 2004-10-04 11:14:12 +00:00
Ruslan Ermilov
eccea571a7 Mechanically kill hard sentence breaks. 2004-07-02 21:04:19 +00:00
Mark Murray
6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
Jun Kuriyama
b800f53d91 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 van Rooij
f3761deee3 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
Bruce Evans
8f1f433834 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
David E. O'Brien
09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
Tom Rhodes
02b911053d Cross ref chflags(1).
Suggested by:	Craig Carey <research@ijs.co.nz) on -doc.
2003-02-04 20:38:51 +00:00
Tom Rhodes
7d971bbf29 s/filesystem/file system/ as discussed on -developers 2002-08-21 17:32:44 +00:00
Sheldon Hearn
ced4deb156 Revert previous delta, which is not required with rev 1.5 of
src/contrib/gcc/c-format.c .
2002-07-15 12:08:21 +00:00
Tim J. Robbins
90833c99de 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
Sheldon Hearn
a3ee32f3f7 Set WFORMAT=0, because our compiler currently complains about NULL
arg 2 to err() and friends, and warnings are promoted to errors.

This allows the following revisions to be reverted:

	rev 1.39	src/bin/cp/cp.c
	rev 1.26	src/bin/chmod/chmod.c
	rev 1.40	src/bin/rm/rm.c

The following revisions can already be reverted, because they were
already covered by WFORMAT=0:

	rev 1.8		src/bin/ls/lomac.c
	rev 1.63	src/bin/ls/ls.c
	rev 1.8		src/bin/ps/lomac.c
	rev 1.34	src/bin/rcp/rcp.c
2002-07-11 08:45:38 +00:00
Matthew Dillon
5ad9e45f96 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
David E. O'Brien
2749b14129 Consistently use FBSDID 2002-06-30 05:15:05 +00:00
Tim J. Robbins
e9393a92a6 Reject options, handle "--" correctly in unlink(1). 2002-05-30 01:05:15 +00:00
Tom Rhodes
ebd4324457 Consistancy check s/file system/filesystem/
Reviewed by:	brian
2002-05-16 01:57:20 +00:00
Doug White
0551940858 Update STANDARDS section on rm(1) to reflect current conformance.
PR:		35471
2002-03-02 05:10:11 +00:00
Warner Losh
fc69394f0a 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
Warner Losh
46251dde8f 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 Rizzo
69393d0646 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
David E. O'Brien
a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Dima Dorfman
b91c884fda Set WARNS=2 on programs which compile cleanly.
Submitted by:	Mike Barcroft <mike@q9media.com>
2001-07-15 10:30:46 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
754e501c71 Removed wrong cast for fts_open()'s third argument. 2001-06-13 15:01:25 +00:00
Ruslan Ermilov
47dec78170 mdoc(7) police: use the default ``file ...'' feature of the .Ar macro. 2001-02-13 09:56:35 +00:00
David E. O'Brien
b6f80a8e3d Display pathname of item being rm'ed.
Submitted by:	Peter Pentchev <roam@orbitel.bg>
2000-12-20 08:31:26 +00:00
Ruslan Ermilov
12e720d78b Prepare for mdoc(7)NG. 2000-12-15 17:37:31 +00:00
Ruslan Ermilov
be8b149795 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 11:39:41 +00:00
Josef Karthauser
141d77b8cb Switch over to using the new fflagstostr and strtofflags library calls. 2000-06-17 14:19:33 +00:00
Jeroen Ruigrok van der Werven
69757cf969 Remove unused #include. 2000-05-01 18:34:36 +00:00
Josef Karthauser
418d67b0d9 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
Josef Karthauser
18c0eeddf7 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
Bruce Evans
ed92ab90fc Actually remove unrequired SRCS. 2000-01-05 19:22:10 +00:00
Josef Karthauser
cd2a718f1e Added missing DPADD's. Removed unrequired SRCS's.
Obtained from:	bde
2000-01-01 15:44:11 +00:00
Josef Karthauser
edc2844c9f Moved flags_to_string and string_to_flags into libutil. It's used in
many places nowadays.
1999-12-30 13:15:15 +00:00
Sheldon Hearn
9a73cc73e9 Fix cut'n'paste niggles in previous commit. 1999-12-21 08:57:58 +00:00
Sheldon Hearn
d71e172ac6 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
Michael Haro
0efa204039 brucify
Reviewed by:	obrien
1999-11-28 09:34:21 +00:00
Bruce Evans
4a086b52ca 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
Michael Haro
777d1f8281 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
Michael Haro
0b93733576 fix rm -r
Submitted by:	John Hay -- John.Hay@mikom.csir.co.za
1999-08-29 19:57:03 +00:00
Michael Haro
bfbdd545e1 add verbose flag
exit(1) --> exit(EX_USAGE)

Reviewed by:	obrien
1999-08-29 02:20:26 +00:00
Peter Wemm
2a4562393f $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
Kris Kennaway
f80db2b881 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
Jordan K. Hubbard
0e8f2d6c1a 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
Garrett Wollman
bd98a81593 Fix synopsis to match 1003.2. Add text describing the way in which
our implementation does not meet 1003.2 (rather than the now outdated
``is expected to comply' language).
1999-01-28 17:41:02 +00:00
Philippe Charnier
f43e9d2251 .Nm rm -> .Nm. 1998-05-18 06:37:35 +00:00
Steve Price
395f4bf0be 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 Price
41cc862cc2 Remove #if(n)def BSD_4_4_LITE cruft and change sccsid to rcsid. 1997-08-07 15:37:47 +00:00
Doug Rabson
e9dff5569a Enable whiteout code since we now have the lite2 support for them. 1997-04-29 10:03:10 +00:00
Mike Pritchard
fa10160c65 Provide examples of how to remove file names that begin with
a dash in non-getopt implementations.  E.g.:
	rm /home/mpp/-filename
	rm ./-filename

Requested by: bde
1997-04-09 05:04:43 +00:00
Mike Pritchard
fe83da2eec Improve the wording in the NOTES section. Closes PR# 3223. 1997-04-08 20:27:48 +00:00
Warner Losh
93ef08af3e 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 Wemm
b97fa2ef50 Revert $FreeBSD$ to $Id$ 1997-02-22 14:13:04 +00:00
Jordan K. Hubbard
1130b656e5 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 Price
1f64b5c98e 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
Wolfram Schneider
b8923d4cc0 [HISTORY] command appeared in Version 1 AT&T UNIX
Obtained from: A Quarter Century of UNIX, Peter H. Salus, page 41
1996-08-29 18:06:19 +00:00
Wolfram Schneider
b0205aff7f 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
Paul Traina
22471d5338 Don't initialize udata, fix usage string 1996-02-19 05:57:22 +00:00
Wolfram Schneider
d7e0e5ca0f delete my last commit
Submitted by:	pst, ache
1996-02-19 00:44:19 +00:00
Paul Traina
daf6f1eb4e Remove unnecessary '?' case and don't zero global udata, it's already zero 1996-02-18 19:54:04 +00:00
Wolfram Schneider
f44290853f update usage string
all flag variables initialized with zero
respond `Y' is equal to `y'
1996-02-18 19:00:59 +00:00
Andrey A. Chernov
6b4198130e Allow root to delete uchg/uappnd files 1995-04-13 13:35:09 +00:00
David Greenman
89730b290a Added $Id$ 1994-09-24 02:59:15 +00:00
Bruce Evans
9fb420314e Remove redundant declarations that were added in the previous commit. 1994-09-21 22:31:01 +00:00
Poul-Henning Kamp
67a3d3a8d3 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
Andreas Schulz
a8c32ea5a1 Reviewed by:
Submitted by:
Added the FTS_NOCHDIR flag to the fts-open call. This is needed, so that
the fts don't change the current directory for rm and subsequent calls
to rmdir with relative pathnames don't fail.
Pulled over the bugfix in 1.1.5.
1994-08-28 18:34:50 +00:00
Rodney W. Grimes
4b88c807ea BSD 4.4 Lite bin Sources 1994-05-26 06:18:55 +00:00