summaryrefslogtreecommitdiff
path: root/bin/csh
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-23 16:40:45 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-23 16:40:45 +0000
commit49ef61b214d2c1c164fa8ede893b9e0e73405f71 (patch)
treeea46e8a99b06e26a2054809b807e0271485d96d6 /bin/csh
parent1294b4ef28fe59ca2c2b47c0bb88347578356cd1 (diff)
Don't not use getopt() in printf(1) since it causes formats beginning
with a '-' to be interpreted as flags. Noticed by Alan Barrett. There is really no reason for this to be a builtin in csh...
Diffstat (limited to 'bin/csh')
-rw-r--r--bin/csh/printf.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/bin/csh/printf.c b/bin/csh/printf.c
index 2a25b034ce7..4cfc00b8b1d 100644
--- a/bin/csh/printf.c
+++ b/bin/csh/printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printf.c,v 1.14 2003/06/11 21:09:50 deraadt Exp $ */
+/* $OpenBSD: printf.c,v 1.15 2003/06/23 16:40:44 millert Exp $ */
/* $NetBSD: printf.c,v 1.6 1995/03/21 09:03:15 cgd Exp $ */
/*
@@ -42,7 +42,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)printf.c 8.1 (Berkeley) 7/20/93";
#else
-static char rcsid[] = "$OpenBSD: printf.c,v 1.14 2003/06/11 21:09:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: printf.c,v 1.15 2003/06/23 16:40:44 millert Exp $";
#endif
#endif /* not lint */
@@ -94,16 +94,7 @@ main(int argc, char *argv[])
int ch, end, fieldwidth, precision;
char convch, nextch, *format, *fmt, *start;
- while ((ch = getopt(argc, argv, "")) != -1)
- switch (ch) {
- default:
- usage();
- return (1);
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 1) {
+ if (argc < 2) {
usage();
return (1);
}
@@ -119,7 +110,7 @@ main(int argc, char *argv[])
skip1 = "#-+ 0";
skip2 = "*0123456789";
- escape(fmt = format = *argv); /* backslash interpretation */
+ escape(fmt = format = *++argv); /* backslash interpretation */
gargv = ++argv;
for (;;) {
end = 0;