Commit faaec04c authored by jan.koester's avatar jan.koester
Browse files

find renew

parent a657938f
Loading
Loading
Loading
Loading
+26 −3
Changes for commands/filesystem/find.cpp: 26 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -615,10 +615,33 @@ namespace fresh { namespace cmd {
            // leading -H/-L/-P options
            for(; i<argc; ++i) {
                std::string a = argv[i];
                if(a=="-L") s.followLinks=true;
                else if(a=="-H" || a=="-P") s.followLinks=false;
                else break;

                // Accept escaped GNU find parentheses.
                if(a == "\\(")
                    a = "(";
                else if(a == "\\)")
                    a = ")";

                // Some shell/build-script combinations can pass the
                // opening parenthesis attached to the first predicate:
                // "(-name" -> "(" + "-name"
                if(a.size() > 2 && a.rfind("(-", 0) == 0) {
                    p.toks.push_back("(");
                    p.toks.push_back(a.substr(1));
                    continue;
                }

                // Same for a closing parenthesis attached to a predicate.
                if(a.size() > 2 && a.back() == ')' &&
                a != ")") {
                    p.toks.push_back(a.substr(0, a.size() - 1));
                    p.toks.push_back(")");
                    continue;
                }

                p.toks.push_back(a);
            }

            std::vector<std::string> paths;
            for(; i<argc; ++i){
                std::string a=argv[i];