<commit_before>#!/bin/sh

## usage gentexi BINARY
if test -x "${1}"; then
	BINARY="${1}"
	BINNAME=$(basename "${BINARY}")
	shift
else
	echo "${1} not a binary" >&2
	exit 1
fi

if test "${#}" -eq 0; then
	exit 0
fi

## backport from dt-test.sh
tsp_create_env()
{
	TS_TMPDIR="`basename "${BINARY}"`.tmpd"
	rm -rf "${TS_TMPDIR}" || return 1
	mkdir "${TS_TMPDIR}" || return 1

	TS_STDIN="${TS_TMPDIR}/stdin"
	TS_EXP_STDOUT="${TS_TMPDIR}/exp_stdout"
	TS_EXP_STDERR="${TS_TMPDIR}/exp_stderr"
	TS_OUTFILE="${TS_TMPDIR}/tool_outfile"
	TS_EXP_EXIT_CODE="0"
	TS_DIFF_OPTS=""

	tool_stdout="${TS_TMPDIR}/tool_stdout"
	tool_stderr="${TS_TMPDIR}/tool_sterr"
}

tsp_reset_env()
{
	zero()
	{
		dd if=/dev/zero of="${1}" count=0 status=noxfer 2>/dev/null
	}

	zero "${TS_STDIN}"
	zero "${TS_EXP_STDOUT}"
	zero "${TS_EXP_STDERR}"
	zero "${TS_OUTFILE}"

	zero "${tool_stdout}"
	zero "${tool_stderr}"
}

## now go for examples
myexit()
{
	if test "${1}" = "0"; then
		rm -rf "${TS_TMPDIR}"
	fi
	exit ${1:-1}
}

## setup
fail=0
tsp_create_env || myexit 1

. $(dirname "${0}")"/genex"

echo "[EXAMPLES]"
for i; do
	tsp_reset_env

	. "${i}"

	## double check we're in the right tool
	if test "${TOOL}" != "${BINNAME}"; then
		continue
	fi

	echo
	genex "${BINARY}" "${BINNAME}" "${CMDLINE}" "${TS_STDIN}" | \
		sed 's/^/  /'
	echo
done

myexit 0<commit_msg>chore, adapt genh2m.sh script to clit files<commit_after>#!/bin/sh

## usage gentexi BINARY
if test -x "${1}"; then
	BINARY="${1}"
	BINNAME=$(basename "${BINARY}")
	shift
else
	echo "${1} not a binary" >&2
	exit 1
fi

if test "${#}" -eq 0; then
	exit 0
fi

echo "[EXAMPLES]"
for i; do
	echo
	sed '/^#!/d; /ends here$/d; /^[ \t]*$/d;
s/@/@@/g; s/{/@{/g; s/}/@}/g
s/^/  /' "${i}"
	echo
done

exit 0
{'fraction_non_alphanumeric': 0.22010398613518198, 'fraction_numerical': 0.01733102253032929, 'mean_word_length': 4.0791788856304985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2828077', 'n_tokens_mistral': 803, 'n_tokens_neox': 770, 'n_words': 186}