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.
This commit is contained in:
Warner Losh 2009-04-29 18:08:18 +00:00
parent 7074cfa223
commit b5260db685
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=191670

View File

@ -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;
}