aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/dd.c15
-rw-r--r--coreutils/ls.c2
-rw-r--r--coreutils/mkdir.c3
-rw-r--r--coreutils/rm.c5
4 files changed, 18 insertions, 7 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 9468cddfc..39c6a6263 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv)
intotal = 0;
outTotal = 0;
- if (inFile == NULL)
- inFd = STDIN;
+ if (inFile == NULL) {
+ struct stat statBuf;
+ inFd = fileno(stdin);
+ if (fstat(inFd, &statBuf) < 0)
+ exit( FALSE);
+ count = statBuf.st_size;
+ }
else
inFd = open (inFile, 0);
@@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv)
}
if (outFile == NULL)
- outFd = STDOUT;
+ outFd = fileno(stdout);
else
outFd = creat (outFile, 0666);
@@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv)
if (inCc < 0) {
perror (inFile);
goto cleanup;
+ } else if (inCc == 0) {
+ goto cleanup;
}
intotal += inCc;
cp = buf;
@@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv)
if (outCc < 0) {
perror (outFile);
goto cleanup;
+ } else if (outCc == 0) {
+ goto cleanup;
}
inCc -= outCc;
diff --git a/coreutils/ls.c b/coreutils/ls.c
index f09cbbc22..0558bb227 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -475,7 +475,7 @@ ls_main(int argc, char * * argv)
/* choose a display format */
if (display_fmt == FMT_AUTO)
- display_fmt = isatty(STDOUT_FILENO) ? FMT_COLUMNS : FMT_SINGLE;
+ display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE;
if (argi < argc - 1)
opts |= DISP_DIRNAME; /* 2 or more items? label directories */
#ifdef FEATURE_AUTOWIDTH
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 28315cad6..2cd178805 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -85,8 +85,9 @@ extern int mkdir_main(int argc, char **argv)
fprintf(stderr, "%s: File exists\n", *argv);
exit( FALSE);
}
- if (parentFlag == TRUE)
+ if (parentFlag == TRUE) {
createPath(*argv, mode);
+ }
else {
if (mkdir (*argv, mode) != 0) {
perror(*argv);
diff --git a/coreutils/rm.c b/coreutils/rm.c
index ba5d30e92..ee434fb39 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -31,8 +31,8 @@
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
"Remove (unlink) the FILE(s).\n\n"
"Options:\n"
-"\t-f\tremove existing destinations, never prompt\n"
-"\t-r\tremove the contents of directories recursively\n";
+"\t-f\t\tremove existing destinations, never prompt\n"
+"\t-r or -R\tremove the contents of directories recursively\n";
static int recursiveFlag = FALSE;
@@ -72,6 +72,7 @@ extern int rm_main(int argc, char **argv)
while (**argv == '-') {
while (*++(*argv))
switch (**argv) {
+ case 'R':
case 'r':
recursiveFlag = TRUE;
break;