Deleted Added
full compact
mv.c (29933) mv.c (30106)
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ken Smith of The State University of New York at Buffalo.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ken Smith of The State University of New York at Buffalo.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 19 unchanged lines hidden (view full) ---

28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $Id: mv.c,v 1.13 1997/03/28 15:24:26 imp Exp $
36 * $Id: mv.c,v 1.14 1997/09/28 10:41:40 wosch Exp $
37 */
38
39#ifndef lint
40static char const copyright[] =
41"@(#) Copyright (c) 1989, 1993, 1994\n\
42 The Regents of the University of California. All rights reserved.\n";
43#endif /* not lint */
44

--- 107 unchanged lines hidden (view full) ---

152 */
153 if (!fflg && !access(to, F_OK)) {
154
155 /* prompt only if source exist */
156 if (lstat(from, &sb) == -1) {
157 warn("%s", from);
158 return (1);
159 }
37 */
38
39#ifndef lint
40static char const copyright[] =
41"@(#) Copyright (c) 1989, 1993, 1994\n\
42 The Regents of the University of California. All rights reserved.\n";
43#endif /* not lint */
44

--- 107 unchanged lines hidden (view full) ---

152 */
153 if (!fflg && !access(to, F_OK)) {
154
155 /* prompt only if source exist */
156 if (lstat(from, &sb) == -1) {
157 warn("%s", from);
158 return (1);
159 }
160
160
161#define YESNO "(y/n [n]) "
161 ask = 0;
162 if (iflg) {
162 ask = 0;
163 if (iflg) {
163 (void)fprintf(stderr, "overwrite %s? ", to);
164 (void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
164 ask = 1;
165 } else if (access(to, W_OK) && !stat(to, &sb)) {
166 strmode(sb.st_mode, modep);
165 ask = 1;
166 } else if (access(to, W_OK) && !stat(to, &sb)) {
167 strmode(sb.st_mode, modep);
167 (void)fprintf(stderr, "override %s%s%s/%s for %s? ",
168 (void)fprintf(stderr, "override %s%s%s/%s for %s? %s",
168 modep + 1, modep[9] == ' ' ? "" : " ",
169 user_from_uid(sb.st_uid, 0),
169 modep + 1, modep[9] == ' ' ? "" : " ",
170 user_from_uid(sb.st_uid, 0),
170 group_from_gid(sb.st_gid, 0), to);
171 group_from_gid(sb.st_gid, 0), to, YESNO);
171 ask = 1;
172 }
173 if (ask) {
174 first = ch = getchar();
175 while (ch != '\n' && ch != EOF)
176 ch = getchar();
172 ask = 1;
173 }
174 if (ask) {
175 first = ch = getchar();
176 while (ch != '\n' && ch != EOF)
177 ch = getchar();
177 if (first != 'y' && first != 'Y')
178 if (first != 'y' && first != 'Y') {
179 (void)fprintf(stderr, "not overwritten\n");
178 return (0);
180 return (0);
181 }
179 }
180 }
181 if (!rename(from, to))
182 return (0);
183
184 if (errno != EXDEV) {
185 warn("rename %s to %s", from, to);
186 return (1);

--- 148 unchanged lines hidden ---
182 }
183 }
184 if (!rename(from, to))
185 return (0);
186
187 if (errno != EXDEV) {
188 warn("rename %s to %s", from, to);
189 return (1);

--- 148 unchanged lines hidden ---