<commit_before>package aQute.libg.command;

import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import aQute.lib.io.*;
import aQute.service.reporter.*;

public class Command {

	boolean				trace;
	Reporter			reporter;
	List<String>		arguments	= new ArrayList<String>();
	Map<String,String>	variables	= new LinkedHashMap<String,String>();
	long				timeout		= 0;
	File				cwd			= new File("").getAbsoluteFile();
	static Timer		timer		= new Timer(Command.class.getName(), true);
	Process				process;
	volatile boolean	timedout;
	String				fullCommand;

	public Command(String fullCommand) {
		this.fullCommand = fullCommand;
	}

	public Command() {}

	public int execute(Appendable stdout, Appendable stderr) throws Exception {
		return execute((InputStream) null, stdout, stderr);
	}

	public int execute(String input, Appendable stdout, Appendable stderr) throws Exception {
		InputStream in = new ByteArrayInputStream(input.getBytes("UTF-8"));
		return execute(in, stdout, stderr);
	}

	public int execute(final InputStream in, Appendable stdout, Appendable stderr) throws Exception {
		if (reporter != null) {
			reporter.trace("executing cmd: %s", arguments);
		}

		String args[] = arguments.toArray(new String[arguments.size()]);
		String vars[] = new String[variables.size()];
		int i = 0;
		for (Entry<String,String> s : variables.entrySet()) {
			vars[i++] = s.getKey() + "=" + s.getValue();
		}

		if (fullCommand == null)
			process = Runtime.getRuntime().exec(args, vars.length == 0 ? null : vars, cwd);
		else
			process = Runtime.getRuntime().exec(fullCommand, vars.length == 0 ? null : vars, cwd);

		// Make sure the command will not linger when we go
		Runnable r = new Runnable() {
			public void run() {
				process.destroy();
			}
		};
		Thread hook = new Thread(r, arguments.toString());
		Runtime.getRuntime().addShutdownHook(hook);
		TimerTask timer = null;
		final OutputStream stdin = process.getOutputStream();
		Thread rdInThread = null;

		if (timeout != 0) {
			timer = new TimerTask() {
				@Override
				public void run() {
					timedout = true;
					process.destroy();
				}
			};
			Command.timer.schedule(timer, timeout);
		}

		final AtomicBoolean finished = new AtomicBoolean(false);
		InputStream out = process.getInputStream();
		try {<commit_msg>Got a weird error on Override, not sure how this could happen<commit_after>package aQute.libg.command;

import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import aQute.lib.io.*;
import aQute.service.reporter.*;

public class Command {

	boolean				trace;
	Reporter			reporter;
	List<String>		arguments	= new ArrayList<String>();
	Map<String,String>	variables	= new LinkedHashMap<String,String>();
	long				timeout		= 0;
	File				cwd			= new File("").getAbsoluteFile();
	static Timer		timer		= new Timer(Command.class.getName(), true);
	Process				process;
	volatile boolean	timedout;
	String				fullCommand;

	public Command(String fullCommand) {
		this.fullCommand = fullCommand;
	}

	public Command() {}

	public int execute(Appendable stdout, Appendable stderr) throws Exception {
		return execute((InputStream) null, stdout, stderr);
	}

	public int execute(String input, Appendable stdout, Appendable stderr) throws Exception {
		InputStream in = new ByteArrayInputStream(input.getBytes("UTF-8"));
		return execute(in, stdout, stderr);
	}

	public int execute(final InputStream in, Appendable stdout, Appendable stderr) throws Exception {
		if (reporter != null) {
			reporter.trace("executing cmd: %s", arguments);
		}

		String args[] = arguments.toArray(new String[arguments.size()]);
		String vars[] = new String[variables.size()];
		int i = 0;
		for (Entry<String,String> s : variables.entrySet()) {
			vars[i++] = s.getKey() + "=" + s.getValue();
		}

		if (fullCommand == null)
			process = Runtime.getRuntime().exec(args, vars.length == 0 ? null : vars, cwd);
		else
			process = Runtime.getRuntime().exec(fullCommand, vars.length == 0 ? null : vars, cwd);

		// Make sure the command will not linger when we go
		Runnable r = new Runnable() {
			public void run() {
				process.destroy();
			}
		};
		Thread hook = new Thread(r, arguments.toString());
		Runtime.getRuntime().addShutdownHook(hook);
		TimerTask timer = null;
		final OutputStream stdin = process.getOutputStream();
		Thread rdInThread = null;

		if (timeout != 0) {
			timer = new TimerTask() {
				//@Override TODO why did this not work? TimerTask implements Runnable
				public void run() {
					timedout = true;
					process.destroy();
				}
			};
			Command.timer.schedule(timer, timeout);
		}

		final AtomicBoolean finished = new AtomicBoolean(false);
		InputStream out = process.getInputStream();
		try {
{'fraction_non_alphanumeric': 0.12928541924824452, 'fraction_numerical': 0.0024783147459727386, 'mean_word_length': 4.0082730093071355, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1206874', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1492, 'n_words': 422}