<commit_before>package jnr.process;

import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
import jnr.posix.SpawnAttribute;
import jnr.posix.SpawnFileAction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * Created by headius on 1/19/15.
 */
public class ProcessBuilder {
    private List<String> command;
    private static final POSIX posix = POSIXFactory.getPOSIX();

    public ProcessBuilder(List<String> command) {
        this.command = new ArrayList<String>(command);
    }

    public ProcessBuilder(String... command) {
        this.command = Arrays.asList(command);
    }

    public List<String> command() {
        return new ArrayList<String>(command);
    }

    public void command(List<String> command) {
        this.command = new ArrayList<String>(command);
    }

    public void command(String... command) {
        this.command = Arrays.asList(command);
    }

    public Process start() {
        int[] stdin = new int[2];
        int[] stdout = new int[2];
        int[] stderr = new int[2];

        // prepare all pipes
        posix.pipe(stdin);
        posix.pipe(stdout);
        posix.pipe(stderr);

        // build env list
        ArrayList<String> envp = new ArrayList<String>();
        for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
            envp.add(entry.getKey() + "=" + entry.getValue());
        }

        // spawn process, closing parent's descriptors in child
        long pid = posix.posix_spawnp(
                command.get(0),
                Arrays.asList(
                        SpawnFileAction.dup(stdin[0], 0),
                        SpawnFileAction.dup(stdout[1], 1),
                        SpawnFileAction.dup(stderr[1], 2),
                        SpawnFileAction.close(stdin[1]),
                        SpawnFileAction.close(stdout[0]),
                        SpawnFileAction.close(stderr[0])),
                command,
                envp);

        // close child's descriptors in parent
        posix.close(stdin[0]);
        posix.close(stdout[1]);
        posix.close(stderr[1]);

        // construct a Process
        return new Process(posix, pid, stdin[1], stdout[0], stderr[0]);
    }
}
<commit_msg>Make ProcessBuilder's command() return this, just like java.lang.ProcessBuilder<commit_after>package jnr.process;

import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
import jnr.posix.SpawnAttribute;
import jnr.posix.SpawnFileAction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * Created by headius on 1/19/15.
 */
public class ProcessBuilder {
    private List<String> command;
    private static final POSIX posix = POSIXFactory.getPOSIX();

    public ProcessBuilder(List<String> command) {
        this.command = new ArrayList<String>(command);
    }

    public ProcessBuilder(String... command) {
        this.command = Arrays.asList(command);
    }

    public List<String> command() {
        return new ArrayList<String>(command);
    }

    public ProcessBuilder command(List<String> command) {
        this.command = new ArrayList<String>(command);
        return this;
    }

    public ProcessBuilder command(String... command) {
        this.command = Arrays.asList(command);
        return this;
    }

    public Process start() {
        int[] stdin = new int[2];
        int[] stdout = new int[2];
        int[] stderr = new int[2];

        // prepare all pipes
        posix.pipe(stdin);
        posix.pipe(stdout);
        posix.pipe(stderr);

        // build env list
        ArrayList<String> envp = new ArrayList<String>();
        for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
            envp.add(entry.getKey() + "=" + entry.getValue());
        }

        // spawn process, closing parent's descriptors in child
        long pid = posix.posix_spawnp(
                command.get(0),
                Arrays.asList(
                        SpawnFileAction.dup(stdin[0], 0),
                        SpawnFileAction.dup(stdout[1], 1),
                        SpawnFileAction.dup(stderr[1], 2),
                        SpawnFileAction.close(stdin[1]),
                        SpawnFileAction.close(stdout[0]),
                        SpawnFileAction.close(stderr[0])),
                command,
                envp);

        // close child's descriptors in parent
        posix.close(stdin[0]);
        posix.close(stdout[1]);
        posix.close(stderr[1]);

        // construct a Process
        return new Process(posix, pid, stdin[1], stdout[0], stderr[0]);
    }
}

{'fraction_non_alphanumeric': 0.12153069806560135, 'fraction_numerical': 0.010092514718250631, 'mean_word_length': 2.1628989361702127, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6604867', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1372, 'n_words': 301}