summaryrefslogtreecommitdiffstats
path: root/bin/rm
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2009-04-29 18:08:18 +0000
committerimp <imp@FreeBSD.org>2009-04-29 18:08:18 +0000
commit3eec96d6db439982f1e6f141df4dfafa3a740633 (patch)
treeffa30657da932ebee7e6fb5ce24f210fa40a482c /bin/rm
parente730a094f422be0a895e4fbd07e7f1c0b0a28e43 (diff)
downloadFreeBSD-src-3eec96d6db439982f1e6f141df4dfafa3a740633.zip
FreeBSD-src-3eec96d6db439982f1e6f141df4dfafa3a740633.tar.gz
Implement ^T support for rm: now it will report the next file it
removes when you hit ^T. This is similar to what's done for cp. The signal handler and type definitions for "info" were borrowed directly from cp.
Diffstat (limited to 'bin/rm')
-rw-r--r--bin/rm/rm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index 25a984e..f9316bc 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
int rflag, Iflag;
uid_t uid;
+volatile sig_atomic_t info;
int check(char *, char *, struct stat *);
int check2(char **);
@@ -68,6 +69,7 @@ void checkslash(char **);
void rm_file(char **);
int rm_overwrite(char *, struct stat *);
void rm_tree(char **);
+static void siginfo(int __unused);
void usage(void);
/*
@@ -150,6 +152,7 @@ main(int argc, char *argv[])
checkslash(argv);
uid = geteuid();
+ (void)signal(SIGINFO, siginfo);
if (*argv) {
stdin_ok = isatty(STDIN_FILENO);
@@ -266,6 +269,11 @@ rm_tree(char **argv)
if (rval == 0 && vflag)
(void)printf("%s\n",
p->fts_path);
+ if (rval == 0 && info) {
+ info = 0;
+ (void)printf("%s\n",
+ p->fts_path);
+ }
continue;
}
break;
@@ -276,6 +284,11 @@ rm_tree(char **argv)
if (vflag)
(void)printf("%s\n",
p->fts_path);
+ if (info) {
+ info = 0;
+ (void)printf("%s\n",
+ p->fts_path);
+ }
continue;
}
break;
@@ -297,6 +310,11 @@ rm_tree(char **argv)
if (rval == 0 && vflag)
(void)printf("%s\n",
p->fts_path);
+ if (rval == 0 && info) {
+ info = 0;
+ (void)printf("%s\n",
+ p->fts_path);
+ }
continue;
}
}
@@ -369,6 +387,10 @@ rm_file(char **argv)
}
if (vflag && rval == 0)
(void)printf("%s\n", f);
+ if (info && rval == 0) {
+ info = 0;
+ (void)printf("%s\n", f);
+ }
}
}
@@ -592,3 +614,10 @@ usage(void)
" unlink file");
exit(EX_USAGE);
}
+
+static void
+siginfo(int sig __unused)
+{
+
+ info = 1;
+}
OpenPOWER on IntegriCloud