Add verbose processing flag.

This commit is contained in:
David E. O'Brien 1999-09-11 10:06:56 +00:00
parent e244f2ac53
commit b598b07322
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51148
2 changed files with 21 additions and 5 deletions

View file

@ -43,11 +43,11 @@
.Nd make links
.Sh SYNOPSIS
.Nm ln
.Op Fl fs
.Op Fl fsv
.Ar source_file
.Op target_file
.Nm ln
.Op Fl fs
.Op Fl fsv
.Ar source_file ...
.Op target_dir
.Sh DESCRIPTION
@ -72,6 +72,10 @@ The options are as follows:
Unlink any already existing file, permitting the link to occur.
.It Fl s
Create a symbolic link.
.It Fl v
Cause
.Nm
to be verbose, showing files as they are processed.
.El
.Pp
By default,
@ -125,6 +129,10 @@ The links made will have the same name as the files being linked to.
.Xr stat 2 ,
.Xr symlink 2 ,
.Xr symlink 7
.Sh COMPATIBILITY
The
.Fl v
option is non-standard and its use in scripts is not recommended.
.Sh HISTORY
An
.Nm

View file

@ -57,8 +57,10 @@ static const char rcsid[] =
int fflag; /* Unlink existing files. */
int sflag; /* Symbolic, not hard, link. */
int vflag; /* Verbose output. */
/* System link call. */
int (*linkf) __P((const char *, const char *));
char linkch;
int linkit __P((char *, char *, int));
void usage __P((void));
@ -73,7 +75,7 @@ main(argc, argv)
int ch, exitval;
char *sourcedir;
while ((ch = getopt(argc, argv, "fs")) != -1)
while ((ch = getopt(argc, argv, "fsv")) != -1)
switch (ch) {
case 'f':
fflag = 1;
@ -81,6 +83,9 @@ main(argc, argv)
case 's':
sflag = 1;
break;
case 'v':
vflag = 1;
break;
case '?':
default:
usage();
@ -90,6 +95,7 @@ main(argc, argv)
argc -= optind;
linkf = sflag ? symlink : link;
linkch = sflag ? '-' : '=';
switch(argc) {
case 0:
@ -153,6 +159,8 @@ linkit(target, source, isdir)
warn("%s", source);
return (1);
}
if (vflag)
(void)printf("%s %c> %s\n", source, linkch, target);
return (0);
}
@ -160,7 +168,7 @@ void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: ln [-fs] file1 file2",
" ln [-fs] file ... directory");
"usage: ln [-fsv] file1 file2",
" ln [-fsv] file ... directory");
exit(1);
}