core/src/main/java/org/jruby/util/io/PopenExecutor.java
private long procSpawnSh(Ruby runtime, ExecArg eargp, String str, String[] envp) {
        char[] sChars;
        int s = 0;

        sChars = str.toCharArray();
        while (s < sChars.length && (sChars[s] == ' ' || sChars[s] == '\t' || sChars[s] == '\n'))
            s++;

        if (s >= sChars.length) {
            errno = Errno.ENOENT;
            return -1;
        }

        // TODO: Windows
        if (Platform.IS_WINDOWS) { // #ifdef _WIN32
//            rb_w32_uspawn(P_OVERLAY, (char *)str, 0);
            return -1;
        } else {
//            #if defined(__CYGWIN32__) || defined(__EMX__)
//            {
//                char fbuf[MAXPATHLEN];
//                char *shell = dln_find_exe_r("sh", 0, fbuf, sizeof(fbuf));
//                int status = -1;
//                if (shell)
//                    execl(shell, "sh", "-c", str, (char *) NULL);
//                else
//                status = system(str);
//                if (status != -1)
//                    exit(status);
//            }
//            #else
            long ret = runtime.getPosix().posix_spawnp(
                    "/bin/sh",
                    eargp.fileActions,
                    eargp.attributes,
                    Arrays.asList("sh", "-c", str),
                    envp == null ? Collections.EMPTY_LIST : Arrays.asList(envp));

            if (ret == -1) {
                errno = Errno.valueOf(runtime.getPosix().errno());
            }

            return ret;
        }
    }
// MRI: Basically doing sh processing from proc_exec_sh but for non-fork path
Basically doing sh processing from proc_exec_sh but for non-fork path
Basically doing sh processing from proc_exec_sh but for non - fork path
private long procSpawnSh(Ruby runtime, ExecArg eargp, String str, String[] envp) {
        char[] sChars;
        int s = 0;
        sChars = str.toCharArray();
        while (s < sChars.length && (sChars[s] == ' ' || sChars[s] == '\t' || sChars[s] == '\n'))
            s++;
        if (s >= sChars.length) {
            errno = Errno.ENOENT;
            return -1;
        }
        if (Platform.IS_WINDOWS) { 
            return -1;
        } else {
            long ret = runtime.getPosix().posix_spawnp(
                    "/bin/sh",
                    eargp.fileActions,
                    eargp.attributes,
                    Arrays.asList("sh", "-c", str),
                    envp == null ? Collections.EMPTY_LIST : Arrays.asList(envp));
            if (ret == -1) {
                errno = Errno.valueOf(runtime.getPosix().errno());
            }
            return ret;
        }
    }
private long procSpawnSh ( Ruby runtime , ExecArg eargp , String str , String [ ] envp ) { char [ ] sChars ; int s = 0 ; sChars = str . toCharArray ( ) ; while ( s < sChars . length && ( sChars [ s ] == ' ' || sChars [ s ] == '\t' || sChars [ s ] == '\n' ) ) s ++ ; if ( s >= sChars . length ) { errno = Errno . ENOENT ; return - 1 ; } if ( Platform . IS_WINDOWS ) { return - 1 ; } else { long ret = runtime . getPosix ( ) . posix_spawnp ( "/bin/sh" , eargp . fileActions , eargp . attributes , Arrays . asList ( "sh" , "-c" , str ) , envp == null ? Collections . EMPTY_LIST : Arrays . asList ( envp ) ) ; if ( ret == - 1 ) { errno = Errno . valueOf ( runtime . getPosix ( ) . errno ( ) ) ; } return ret ; } }
MRI: Basically doing sh processing from proc_exec_sh but for non-fork path
MRI : Basically doing sh processing from proc_exec_sh but for non - fork path
// TODO: Windows // #ifdef _WIN32 //            rb_w32_uspawn(P_OVERLAY, (char *)str, 0); //            #if defined(__CYGWIN32__) || defined(__EMX__) //            { //                char fbuf[MAXPATHLEN]; //                char *shell = dln_find_exe_r("sh", 0, fbuf, sizeof(fbuf)); //                int status = -1; //                if (shell) //                    execl(shell, "sh", "-c", str, (char *) NULL); //                else //                status = system(str); //                if (status != -1) //                    exit(status); //            } //            #else