commit d24584466c9ea27451bd9c56804e935247807085
Author:     sin <[email protected]>
AuthorDate: Fri Nov 13 14:29:23 2015 +0000
Commit:     sin <[email protected]>
CommitDate: Fri Nov 13 14:31:34 2015 +0000

    Revert "enmasse: For the special case of 2 args, do not distinguish between 
dirs and files"
    
    This reverts commit a564a67c4ea70e90a4dc543814458e4903869d3e.
    
    Not as trivial as I thought.  This breaks cp when used as:
    cp -r /foo/bar /baz
    
    The old code expands this to:
    cp -r /foo/bar /baz/bar

diff --git a/libutil/enmasse.c b/libutil/enmasse.c
index 97b4957..a2e225a 100644
--- a/libutil/enmasse.c
+++ b/libutil/enmasse.c
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include "../util.h"
@@ -10,11 +11,12 @@
 void
 enmasse(int argc, char *argv[], int (*fn)(const char *, const char *, int))
 {
+       struct stat st;
        char buf[PATH_MAX], *dir;
        int i, len;
        size_t dlen;
 
-       if (argc == 2) {
+       if (argc == 2 && !(stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))) {
                fnck(argv[0], argv[1], fn, 0);
                return;
        } else {

Reply via email to