summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorErik Andersen2000-02-07 05:29:42 +0000
committerErik Andersen2000-02-07 05:29:42 +0000
commitfac10d7c59f7db0facd5fb94de273310b9ec86e6 (patch)
treedccf8f905fc5807239883da9fca6597037d487fc /coreutils
parent50bc101b7d6e847a9a0621ca3eb28c7117d095e5 (diff)
downloadbusybox-fac10d7c59f7db0facd5fb94de273310b9ec86e6.zip
busybox-fac10d7c59f7db0facd5fb94de273310b9ec86e6.tar.gz
A few minor updates. ;-)
Seriously though, read the Changelog for busybox 0.42, which this is about to become... -Erik
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c127
-rw-r--r--coreutils/date.c17
-rw-r--r--coreutils/dd.c37
-rw-r--r--coreutils/du.c34
-rw-r--r--coreutils/head.c2
-rw-r--r--coreutils/length.c2
-rw-r--r--coreutils/ln.c79
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/mkdir.c34
-rw-r--r--coreutils/mv.c112
-rw-r--r--coreutils/printf.c2
-rw-r--r--coreutils/pwd.c3
-rw-r--r--coreutils/sort.c2
-rw-r--r--coreutils/tail.c2
-rw-r--r--coreutils/tee.c2
-rw-r--r--coreutils/uniq.c2
16 files changed, 139 insertions, 320 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
deleted file mode 100644
index e96012d..0000000
--- a/coreutils/cp.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Mini cp implementation for busybox
- *
- *
- * Copyright (C) 1999 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "internal.h"
-#include <stdio.h>
-#include <time.h>
-#include <utime.h>
-#include <dirent.h>
-
-static const char cp_usage[] = "cp [OPTION]... SOURCE DEST\n"
- " or: cp [OPTION]... SOURCE... DIRECTORY\n\n"
- "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
- "\n"
- "\t-a\tsame as -dpR\n"
- "\t-d\tpreserve links\n"
- "\t-p\tpreserve file attributes if possible\n"
- "\t-R\tcopy directories recursively\n";
-
-
-static int recursiveFlag = FALSE;
-static int followLinks = FALSE;
-static int preserveFlag = FALSE;
-static const char *srcName;
-static const char *destName;
-static int destDirFlag = FALSE;
-static int srcDirFlag = FALSE;
-
-static int fileAction(const char *fileName, struct stat* statbuf)
-{
- char newdestName[NAME_MAX];
- char* newsrcName = NULL;
-
- strcpy(newdestName, destName);
- if ( srcDirFlag == TRUE ) {
- if (recursiveFlag!=TRUE ) {
- fprintf(stderr, "cp: %s: omitting directory\n", srcName);
- return( TRUE);
- }
- strcat(newdestName, strstr(fileName, srcName) + strlen(srcName));
- }
-
- if (destDirFlag==TRUE && srcDirFlag == FALSE) {
- if (newdestName[strlen(newdestName)-1] != '/' ) {
- strcat(newdestName, "/");
- }
- newsrcName = strrchr(srcName, '/');
- if (newsrcName && *newsrcName != '\0')
- strcat(newdestName, newsrcName);
- else
- strcat(newdestName, srcName);
- }
-
- return (copyFile(fileName, newdestName, preserveFlag, followLinks));
-}
-
-extern int cp_main(int argc, char **argv)
-{
- if (argc < 3) {
- usage (cp_usage);
- }
- argc--;
- argv++;
-
- /* Parse any options */
- while (**argv == '-') {
- while (*++(*argv))
- switch (**argv) {
- case 'a':
- followLinks = TRUE;
- preserveFlag = TRUE;
- recursiveFlag = TRUE;
- break;
- case 'd':
- followLinks = TRUE;
- break;
- case 'p':
- preserveFlag = TRUE;
- break;
- case 'R':
- recursiveFlag = TRUE;
- break;
- default:
- usage (cp_usage);
- }
- argc--;
- argv++;
- }
-
-
- destName = argv[argc - 1];
- destDirFlag = isDirectory(destName);
-
- if ((argc > 3) && destDirFlag==FALSE) {
- fprintf(stderr, "%s: not a directory\n", destName);
- exit (FALSE);
- }
-
- while (argc-- > 1) {
- srcName = *(argv++);
- srcDirFlag = isDirectory(srcName);
- if (recursiveAction(srcName, recursiveFlag, followLinks, FALSE,
- fileAction, fileAction) == FALSE) {
- exit( FALSE);
- }
- }
- exit( TRUE);
-}
diff --git a/coreutils/date.c b/coreutils/date.c
index 77e7c39..a352892 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -20,6 +20,10 @@
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_invalid_date
+#define bb_need_memory_exhausted
+#include "messages.c"
#include <stdlib.h>
#include <errno.h>
#include <sys/time.h>
@@ -59,7 +63,7 @@ date_conv_time(struct tm *tm_time, const char *t_string) {
&(tm_time->tm_year));
if(nr < 4 || nr > 5) {
- fprintf(stderr, "date: invalid date `%s'\n", t_string);
+ fprintf(stderr, invalid_date, "date", t_string);
exit( FALSE);
}
@@ -152,7 +156,7 @@ date_conv_ftime(struct tm *tm_time, const char *t_string) {
}
- fprintf(stderr, "date: invalid date `%s'\n", t_string);
+ fprintf(stderr, invalid_date, "date", t_string);
exit( FALSE);
@@ -190,7 +194,7 @@ date_main(int argc, char * * argv)
case 'u':
utc = 1;
if (putenv ("TZ=UTC0") != 0) {
- fprintf(stderr,"date: memory exhausted\n");
+ fprintf(stderr, memory_exhausted, "date");
exit( FALSE);
}
/* Look ma, no break. Don't fix it either. */
@@ -204,10 +208,10 @@ date_main(int argc, char * * argv)
}
} else {
if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
- date_fmt = *argv;
+ date_fmt=*argv;
else if (date_str == NULL) {
set_time = 1;
- date_str = *argv;
+ date_str=*argv;
} else {
usage ( date_usage);
}
@@ -241,7 +245,7 @@ date_main(int argc, char * * argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0 ) {
- fprintf(stderr, "date: invalid date `%s'\n", date_str);
+ fprintf(stderr, invalid_date, "date", date_str);
exit( FALSE);
}
@@ -284,4 +288,3 @@ date_main(int argc, char * * argv)
exit( TRUE);
}
-
diff --git a/coreutils/dd.c b/coreutils/dd.c
index bc01eed..3e1024a 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -40,15 +40,16 @@ typedef unsigned long long int uintmax_t;
#endif
static const char dd_usage[] =
-"dd [if=name] [of=name] [bs=n] [count=n]\n\n"
+"dd [if=name] [of=name] [bs=n] [count=n] [skip=n] [seek=n]\n\n"
"Copy a file, converting and formatting according to options\n\n"
"\tif=FILE\tread from FILE instead of stdin\n"
-"\tof=FILE\twrite to FILE instead of stout\n"
-"\tbs=n\tread and write N BYTES at a time\n"
+"\tof=FILE\twrite to FILE instead of stdout\n"
+"\tbs=n\tread and write n bytes at a time\n"
"\tcount=n\tcopy only n input blocks\n"
-//"\tskip=n\tskip n input blocks\n"
+"\tskip=n\tskip n input blocks\n"
+"\tseek=n\tskip n output blocks\n"
"\n"
-"BYTES may be suffixed by w (x2), k (x1024), b (x512), or m (x1024^2).\n";
+"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n";
@@ -61,8 +62,9 @@ extern int dd_main (int argc, char **argv)
int outFd;
int inCc = 0;
int outCc;
- size_t blockSize = 512;
- //uintmax_t skipBlocks = 0;
+ long blockSize = 512;
+ uintmax_t skipBlocks = 0;
+ uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t)-1;
uintmax_t intotal;
uintmax_t outTotal;
@@ -91,16 +93,22 @@ extern int dd_main (int argc, char **argv)
goto usage;
}
}
-#if 0
else if (strncmp(*argv, "skip", 4) == 0) {
- skipBlocks = atoi( *argv);
+ skipBlocks = getNum ((strchr(*argv, '='))+1);
if (skipBlocks <= 0) {
- fprintf (stderr, "Bad skip value %d\n", skipBlocks);
+ fprintf (stderr, "Bad skip value %s\n", *argv);
+ goto usage;
+ }
+
+ }
+ else if (strncmp(*argv, "seek", 4) == 0) {
+ seekBlocks = getNum ((strchr(*argv, '='))+1);
+ if (seekBlocks <= 0) {
+ fprintf (stderr, "Bad seek value %s\n", *argv);
goto usage;
}
}
-#endif
else {
goto usage;
}
@@ -131,7 +139,7 @@ extern int dd_main (int argc, char **argv)
if (outFile == NULL)
outFd = fileno(stdout);
else
- outFd = creat (outFile, 0666);
+ outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (outFd < 0) {
perror (outFile);
@@ -140,10 +148,11 @@ extern int dd_main (int argc, char **argv)
exit( FALSE);
}
- //lseek(inFd, skipBlocks*blockSize, SEEK_SET);
+ lseek(inFd, skipBlocks*blockSize, SEEK_SET);
+ lseek(outFd, seekBlocks*blockSize, SEEK_SET);
//
//TODO: Convert to using fullRead & fullWrite
- // from utilitity.c
+ // from utility.c
// -Erik
while (outTotal < count * blockSize) {
inCc = read (inFd, buf, blockSize);
diff --git a/coreutils/du.c b/coreutils/du.c
index 79b5536..e2cf3f7 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -22,17 +22,18 @@
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_name_too_long
+#include "messages.c"
+
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
-#if 0
-#include <unistd.h>
-#include <sys/stat.h>
-#endif
+#include <sys/param.h> /* for PATH_MAX */
-typedef void (Display)(size_t, char *);
+typedef void (Display)(long, char *);
static const char du_usage[] =
"du [OPTION]... [FILE]...\n\n"
@@ -44,13 +45,13 @@ static int du_depth = 0;
static Display *print;
static void
-print_normal(size_t size, char *filename)
+print_normal(long size, char *filename)
{
- fprintf(stdout, "%-7d %s\n", (size >> 1), filename);
+ fprintf(stdout, "%-7ld %s\n", size, filename);
}
static void
-print_summary(size_t size, char *filename)
+print_summary(long size, char *filename)
{
if (du_depth == 1) {
print_normal(size, filename);
@@ -59,11 +60,11 @@ print_summary(size_t size, char *filename)
/* tiny recursive du */
-static size_t
+static long
du(char *filename)
{
struct stat statbuf;
- size_t sum;
+ long sum;
if ((lstat(filename, &statbuf)) != 0) {
fprintf(stdout, "du: %s: %s\n", filename, strerror(errno));
@@ -80,14 +81,19 @@ du(char *filename)
dir = opendir(filename);
if (!dir) { return 0; }
while ((entry = readdir(dir))) {
- char newfile[512];
+ char newfile[PATH_MAX + 1];
char *name = entry->d_name;
if ( (strcmp(name, "..") == 0)
|| (strcmp(name, ".") == 0))
{ continue; }
+ if (strlen(filename) + strlen(name) + 1 > PATH_MAX) {
+ fprintf(stderr, name_too_long, "du");
+ return 0;
+ }
sprintf(newfile, "%s/%s", filename, name);
+
sum += du(newfile);
}
closedir(dir);
@@ -130,14 +136,14 @@ du_main(int argc, char **argv)
if (i >= argc) {
du(".");
} else {
- int sum;
+ long sum;
for ( ; i < argc; i++) {
sum = du(argv[i]);
- if ((sum) && (isDirectory(argv[i]))) { print_normal(sum, argv[i]); }
+ if ((sum) && (isDirectory(argv[i], FALSE))) { print_normal(sum, argv[i]); }
}
}
exit(0);
}
-/* $Id: du.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
+/* $Id: du.c,v 1.10 2000/02/07 05:29:42 erik Exp $ */
diff --git a/coreutils/head.c b/coreutils/head.c
index bc7f354..b80d065 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -105,4 +105,4 @@ head_main(int argc, char **argv)
exit(0);
}
-/* $Id: head.c,v 1.6 2000/01/25 18:13:53 erik Exp $ */
+/* $Id: head.c,v 1.7 2000/02/07 05:29:42 erik Exp $ */
diff --git a/coreutils/length.c b/coreutils/length.c
index 46242b5..2c83cdf 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -6,7 +6,7 @@
extern int
length_main(int argc, char * * argv)
{
- if ( **(argv+1) == '-' ) {
+ if ( argc != 2 || **(argv+1) == '-' ) {
usage("length string\n");
}
printf("%d\n", strlen(argv[1]));
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 60fe394..f20b340 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -22,26 +22,32 @@
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_name_too_long
+#define bb_need_not_a_directory
+#include "messages.c"
+
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
+#include <sys/param.h> /* for PATH_MAX */
-
-static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
-"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
-"Options:\n"
-"\t-s\tmake symbolic links instead of hard links\n"
-"\t-f\tremove existing destination files\n";
-
+static const char ln_usage[] =
+ "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
+ "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
+ "Options:\n"
+ "\t-s\tmake symbolic links instead of hard links\n"
+ "\t-f\tremove existing destination files\n"
+ "\t-n\tno dereference symlinks - treat like normal file\n";
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
-
+static int followLinks = TRUE;
extern int ln_main(int argc, char **argv)
{
- int status;
- static char* linkName;
+ char *linkName;
+ int linkIntoDirFlag;
if (argc < 3) {
usage (ln_usage);
@@ -59,6 +65,9 @@ extern int ln_main(int argc, char **argv)
case 'f':
removeoldFlag = TRUE;
break;
+ case 'n':
+ followLinks = FALSE;
+ break;
default:
usage (ln_usage);
}
@@ -66,30 +75,54 @@ extern int ln_main(int argc, char **argv)
argv++;
}
-
linkName = argv[argc - 1];
- if ((argc > 3) && !(isDirectory(linkName))) {
- fprintf(stderr, "%s: not a directory\n", linkName);
- exit (FALSE);
+ if (strlen(linkName) > PATH_MAX) {
+ fprintf(stderr, name_too_long, "ln");
+ exit FALSE;
+ }
+
+ linkIntoDirFlag = isDirectory(linkName, TRUE);
+
+ if ((argc > 3) && !linkIntoDirFlag) {
+ fprintf(stderr, not_a_directory, "ln", linkName);
+ exit FALSE;
}
while (argc-- >= 2) {
- if (removeoldFlag==TRUE ) {
+ char srcName[PATH_MAX + 1];
+ int nChars, status;
+
+ if (strlen(*argv) > PATH_MAX) {
+ fprintf(stderr, name_too_long, "ln");
+ exit FALSE;
+ }
+
+ if (followLinks == FALSE) {
+ strcpy(srcName, *argv);
+ } else {
+ /* Warning! This can silently truncate if > PATH_MAX, but
+ I don't think that there can be one > PATH_MAX anyway. */
+ nChars = readlink(*argv, srcName, PATH_MAX);
+ srcName[nChars] = '\0';
+ }
+
+ if (removeoldFlag == TRUE) {
status = ( unlink(linkName) && errno != ENOENT );
- if ( status != 0 ) {
+ if (status != 0) {
perror(linkName);
- exit( FALSE);
+ exit FALSE;
}
}
- if ( symlinkFlag==TRUE)
- status = symlink(*argv, linkName);
+
+ if (symlinkFlag == TRUE)
+ status = symlink(*argv, linkName);
else
- status = link(*argv, linkName);
- if ( status != 0 ) {
+ status = link(*argv, linkName);
+ if (status != 0) {
perror(linkName);
- exit( FALSE);
+ exit FALSE;
}
}
- exit( TRUE);
+ exit TRUE;
}
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 78193e7..450ea18 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -178,7 +178,7 @@ static char append_char(mode_t mode)
static void list_single(const char *name, struct stat *info, const char *fullname)
{
- char scratch[PATH_MAX];
+ char scratch[PATH_MAX + 1];
short len = strlen(name);
#ifdef BB_FEATURE_LS_FILETYPES
char append = append_char(info->st_mode);
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 017ef9b..8e3f51b 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -22,9 +22,13 @@
*/
#include "internal.h"
+#define bb_need_name_too_long
+#define BB_DECLARE_EXTERN
+#include "messages.c"
+
#include <stdio.h>
#include <errno.h>
-#include <sys/param.h>
+#include <sys/param.h> /* for PATH_MAX */
static const char mkdir_usage[] =
"mkdir [OPTION] DIRECTORY...\n\n"
@@ -40,27 +44,27 @@ static mode_t mode = 0777;
extern int mkdir_main(int argc, char **argv)
{
- int i=FALSE;
+ int i = FALSE;
argc--;
argv++;
/* Parse any options */
while (argc > 0 && **argv == '-') {
- while (i==FALSE && *++(*argv)) {
+ while (i == FALSE && *++(*argv)) {
switch (**argv) {
case 'm':
if (--argc == 0)
usage( mkdir_usage);
/* Find the specified modes */
mode = 0;
- if ( parse_mode(*(++argv), &mode) == FALSE ) {
+ if (parse_mode(*(++argv), &mode) == FALSE ) {
fprintf(stderr, "Unknown mode: %s\n", *argv);
- exit( FALSE);
+ exit FALSE;
}
/* Set the umask for this process so it doesn't
* screw up whatever the user just entered. */
umask(0);
- i=TRUE;
+ i = TRUE;
break;
case 'p':
parentFlag = TRUE;
@@ -73,7 +77,6 @@ extern int mkdir_main(int argc, char **argv)
argv++;
}
-
if (argc < 1) {
usage( mkdir_usage);
}
@@ -81,13 +84,16 @@ extern int mkdir_main(int argc, char **argv)
while (argc > 0) {
int status;
struct stat statBuf;
- char buf[NAME_MAX];
-
+ char buf[PATH_MAX + 1];
+ if (strlen(*argv) > PATH_MAX - 1) {
+ fprintf(stderr, name_too_long, "mkdir");
+ exit FALSE;
+ }
strcpy (buf, *argv);
- status=stat(buf, &statBuf);
- if (parentFlag == FALSE && status != -1 && status != ENOENT ) {
+ status = stat(buf, &statBuf);
+ if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
fprintf(stderr, "%s: File exists\n", buf);
- exit( FALSE);
+ exit FALSE;
}
if (parentFlag == TRUE) {
strcat( buf, "/");
@@ -96,13 +102,13 @@ extern int mkdir_main(int argc, char **argv)
else {
if (mkdir (buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);
- exit( FALSE);
+ exit FALSE;
}
}
argc--;
argv++;
}
- exit( TRUE);
+ exit TRUE;
}
diff --git a/coreutils/mv.c b/coreutils/mv.c
deleted file mode 100644
index 467a360..0000000
--- a/coreutils/mv.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Mini mv implementation for busybox
- *
- *
- * Copyright (C) 1999 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include "internal.h"
-#include <stdio.h>
-#include <time.h>
-#include <utime.h>
-#include <dirent.h>
-
-static const char mv_usage[] = "mv SOURCE DEST\n"
-" or: mv SOURCE... DIRECTORY\n\n"
-"Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n";
-
-
-static const char *srcName;
-static const char *destName;
-static int destDirFlag = FALSE;
-static int srcDirFlag = FALSE;
-
-static int fileAction(const char *fileName, struct stat* statbuf)
-{
- char newdestName[NAME_MAX];
- char* newsrcName = NULL;
-
- strcpy(newdestName, destName);
- if ( srcDirFlag == TRUE ) {
- strcat(newdestName, strstr(fileName, srcName) + strlen(srcName));
- }
-
- if (destDirFlag==TRUE && srcDirFlag == FALSE) {
- if (newdestName[strlen(newdestName)-1] != '/' ) {
- strcat(newdestName, "/");
- }
- newsrcName = strrchr(srcName, '/');
- if (newsrcName && *newsrcName != '\0')
- strcat(newdestName, newsrcName);
- else
- strcat(newdestName, srcName);
- }
-
- return (copyFile(fileName, newdestName, TRUE, TRUE));
-}
-
-static int rmfileAction(const char *fileName, struct stat* statbuf)
-{
- if (unlink( fileName) < 0 ) {
- perror( fileName);
- return ( FALSE);
- }
- return ( TRUE);
-}
-
-static int rmdirAction(const char *fileName, struct stat* statbuf)
-{
- if (rmdir( fileName) < 0 ) {
- perror( fileName);
- return ( FALSE);
- }
- return ( TRUE);
-}
-
-
-extern int mv_main(int argc, char **argv)
-{
- if (argc < 3) {
- usage (mv_usage);
- }
- argc--;
- argv++;
-
- destName = argv[argc - 1];
- destDirFlag = isDirectory(destName);
-
- if ((argc > 3) && destDirFlag==FALSE) {
- fprintf(stderr, "%s: not a directory\n", destName);
- exit (FALSE);
- }
-
- while (argc-- > 1) {
- srcName = *(argv++);
- srcDirFlag = isDirectory(srcName);
- if (recursiveAction(srcName, TRUE, TRUE, FALSE,
- fileAction, fileAction) == FALSE) {
- exit( FALSE);
- }
- if (recursiveAction(srcName, TRUE, TRUE, TRUE,
- rmfileAction, rmdirAction) == FALSE) {
- exit( FALSE);
- }
- }
- exit( TRUE);
-}
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 5be3a67..5fd5ea3 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -143,7 +143,7 @@ printf_main(int argc, char** argv)
int args_used;
exit_status = 0;
- if ( **(argv+1) == '-' ) {
+ if ( argc <= 1 || **(argv+1) == '-' ) {
usage (printf_usage);
}
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index c5ce6ff..bacabd7 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -23,11 +23,12 @@
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
+#include <sys/param.h>
extern int
pwd_main(int argc, char * * argv)
{
- char buf[NAME_MAX];
+ char buf[PATH_MAX + 1];
if ( getcwd(buf, sizeof(buf)) == NULL ) {
perror("get working directory");
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 4df5627..d529ce7 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -309,4 +309,4 @@ sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
+/* $Id: sort.c,v 1.10 2000/02/07 05:29:42 erik Exp $ */
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 5198892..0ab8f11 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -33,7 +33,7 @@
and generally busyboxed, Erik Andersen <andersen@lineo.com>
Removed superfluous options and associated code ("-c", "-n", "-q").
- Removed "tail -f" suport for multiple files.
+ Removed "tail -f" support for multiple files.
Both changes by Friedrich Vedder <fwv@myrtle.lahn.de>.
*/
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 8d1ca6e..4c5c691 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -123,4 +123,4 @@ tee_main(int argc, char **argv)
exit(0);
}
-/* $Id: tee.c,v 1.4 1999/12/10 08:25:07 andersen Exp $ */
+/* $Id: tee.c,v 1.5 2000/02/07 05:29:42 erik Exp $ */
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index a7bff54..965d290 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -193,4 +193,4 @@ uniq_main(int argc, char **argv)
exit(0);
}
-/* $Id: uniq.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
+/* $Id: uniq.c,v 1.6 2000/02/07 05:29:42 erik Exp $ */