<commit_before>/*
* Released under the MIT License (MIT), http://opensource.org/licenses/MIT
*
* Copyright (c) 2015 <NAME>, NotTooBad Software (nottoobadsoftware.com)
*
*/

#if !(os(iOS) || os(tvOS) || os(watchOS))

import Foundation

// MARK: Bash

extension CommandRunning {

	func createTask (bash bashcommand: String) -> Process {
		return createTask("/bin/bash", args: ["-c", bashcommand])
	}

	@available(*, unavailable, message: "Use `run(bash: ...).stdout` instead.")
	@discardableResult public func run (bash bashcommand: String, file: String = #file, line: Int = #line) -> String {
		fatalError()
	}

	/**
	Runs a bash shell command.

	- parameter bashcommand: the bash shell command.
	*/
	@discardableResult public func run (bash bashcommand: String, combineOutput: Bool = false) -> RunOutput {
		return run("/bin/bash", "-c", bashcommand, combineOutput: combineOutput)
	}

	/**
	Run bash command and return before it is finished.

	- parameter bashcommand: the bash shell command.
	- returns: an AsyncCommand struct with standard output, standard error and a 'finish' function.
	*/
	public func runAsync (bash bashcommand: String, file: String = #file, line: Int = #line) -> AsyncCommand {
		return AsyncCommand(launch: createTask(bash: bashcommand), file: file, line: line)
	}

	/**
	Run bash command and print output and errors.

	- parameter bashcommand: the bash shell command.
	- throws: a CommandError.ReturnedErrorCode if the return code is anything but 0.
	*/
	public func runAndPrint (bash bashcommand: String) throws {
		let process = createTask(bash: bashcommand)
		process.launch()
		try process.finish()
	}
}

@available(*, unavailable, message: "Use `run(bash: ...).stdout` instead.")
@discardableResult public func run (bash bashcommand: String, file: String = #file, line: Int = #line) -> String {
	fatalError()
}

/**
Runs a bash shell command.

- parameter bashcommand: the bash shell command.
*/
@discardableResult public func run (bash bashcommand: String) -> RunOutput {
	return main.run(bash: bashcommand)
}

/**
Run bash command and return before it is finished.

- parameter bashcommand: the bash shell command.
- returns: an AsyncCommand struct with standard output, standard error and a 'finish' function.
*/
public func runAsync (bash bashcommand: String) -> AsyncCommand {
	return main.runAsync(bash: bashcommand)
}
<commit_msg>Simplify bash run-functions, add file and line numbers to global runAsync(bash:) function.<commit_after>/*
* Released under the MIT License (MIT), http://opensource.org/licenses/MIT
*
* Copyright (c) 2015 <NAME>, NotTooBad Software (nottoob<EMAIL>)
*
*/

#if !(os(iOS) || os(tvOS) || os(watchOS))

import Foundation

// MARK: Bash

extension CommandRunning {

	@available(*, unavailable, message: "Use `run(bash: ...).stdout` instead.")
	@discardableResult public func run (bash bashcommand: String, file: String = #file, line: Int = #line) -> String {
		fatalError()
	}

	/**
	Runs a bash shell command.

	- parameter bashcommand: the bash shell command.
	*/
	@discardableResult public func run (bash bashcommand: String, combineOutput: Bool = false) -> RunOutput {
		return run("/bin/bash", "-c", bashcommand, combineOutput: combineOutput)
	}

	/**
	Run bash command and return before it is finished.

	- parameter bashcommand: the bash shell command.
	- returns: an AsyncCommand struct with standard output, standard error and a 'finish' function.
	*/
	public func runAsync (bash bashcommand: String, file: String = #file, line: Int = #line) -> AsyncCommand {
		return runAsync("/bin/bash", "-c", bashcommand, file: file, line: line)
	}

	/**
	Run bash command and print output and errors.

	- parameter bashcommand: the bash shell command.
	- throws: a CommandError.ReturnedErrorCode if the return code is anything but 0.
	*/
	public func runAndPrint (bash bashcommand: String) throws {
		return try runAndPrint("/bin/bash", "-c", bashcommand)
	}
}

@available(*, unavailable, message: "Use `run(bash: ...).stdout` instead.")
@discardableResult public func run (bash bashcommand: String, file: String = #file, line: Int = #line) -> String {
	fatalError()
}

/**
Runs a bash shell command.

- parameter bashcommand: the bash shell command.
*/
@discardableResult public func run (bash bashcommand: String, combineOutput: Bool = false) -> RunOutput {
	return main.run(bash: bashcommand, combineOutput: combineOutput)
}

/**
Run bash command and return before it is finished.

- parameter bashcommand: the bash shell command.
- returns: an AsyncCommand struct with standard output, standard error and a 'finish' function.
*/
public func runAsync (bash bashcommand: String, file: String = #file, line: Int = #line) -> AsyncCommand {
	return main.runAsync(bash: bashcommand, file: file, line: line)
}

{'fraction_non_alphanumeric': 0.12355779316131739, 'fraction_numerical': 0.0020977554017201595, 'mean_word_length': 4.351290684624018, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 19, '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': '5691157', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1385, 'n_words': 525}