diff options
author | Wolfram Schneider <wosch@FreeBSD.org> | 1996-02-20 23:27:57 +0000 |
---|---|---|
committer | Wolfram Schneider <wosch@FreeBSD.org> | 1996-02-20 23:27:57 +0000 |
commit | 5fd463ac12bdbe3651a889272d31d69e44273899 (patch) | |
tree | ba6b37d679b43b22047c20f8bc255af776226fd1 /bin/mv/mv.c | |
parent | a03bf4ac6a23017bace9678d9cffb7458400e629 (diff) | |
download | src-5fd463ac12bdbe3651a889272d31d69e44273899.tar.gz src-5fd463ac12bdbe3651a889272d31d69e44273899.zip |
option -f and -i are exclusive (Posix)
respond `Y' is equal to `y'
update usage string
prompt only if source exist
Notes
Notes:
svn path=/head/; revision=14166
Diffstat (limited to 'bin/mv/mv.c')
-rw-r--r-- | bin/mv/mv.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 1d05ad9fc715..f9de076c22d5 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mv.c,v 1.5 1996/02/19 00:44:19 wosch Exp $ + * $Id: mv.c,v 1.6 1996/02/19 05:51:13 pst Exp $ */ #ifndef lint @@ -83,9 +83,11 @@ main(argc, argv) switch (ch) { case 'i': iflg = 1; + fflg = 0; break; case 'f': fflg = 1; + iflg = 0; break; default: usage(); @@ -149,6 +151,13 @@ do_move(from, to) * make sure the user wants to clobber it. */ if (!fflg && !access(to, F_OK)) { + + /* prompt only if source exist */ + if (lstat(from, &sb) == -1) { + warn("%s", from); + return (1); + } + ask = 0; if (iflg) { (void)fprintf(stderr, "overwrite %s? ", to); @@ -164,7 +173,7 @@ do_move(from, to) if (ask) { if ((ch = getchar()) != EOF && ch != '\n') while (getchar() != '\n'); - if (ch != 'y') + if (ch != 'y' && ch != 'Y') return (0); } } @@ -299,7 +308,9 @@ copy(from, to) void usage() { - (void)fprintf(stderr, -"usage: mv [-if] src target;\n or: mv [-if] src1 ... srcN directory\n"); + (void)fprintf(stderr, +"\ +usage: mv [-i | -f] src target;\n\ + or: mv [-i | -f] src1 ... srcN directory\n"); exit(1); } |