<commit_before>#!/bin/bash

#  runAs (settings_file_name, command_file_name, password)
if [ $# -eq 3 ];
then
        args=$(cat "$1")
        command=$2
        password=$3
	
	exitCodeFile=$(tempfile)
        chmod a+w $exitCodeFile
	cmd="${0} su $exitCodeFile $command $args"

        started=0
        # run command
        (
		#sleep 1
		#wait for password input
		while [ ! -s $exitCodeFile ];
		do
			sleep .1;
		done
		echo "$password"

		#wait for process finish
		while ps axg | grep "$exitCodeFile" > /dev/null; 
		do 
			sleep .1;
		done
	) | (
		socat - EXEC:"$cmd",pty,ctty
	) 2> >(tee >"$exitCodeFile" >(grep -v "[Pp]assword:" >&2))
	
	#2> >(grep -v "[Pp]assword:")

        # if exit file is empty
        if [ ! -s $exitCodeFile ];
        then
                echo "System or authentication failure" >&2
                exit 255
        fi
	
	exitCode=$(cat "$exitCodeFile")
        rm $exitCodeFile 1> /dev/null 2> /dev/null
        exit $exitCode
fi

# su (su, exit_code_file, command_file_name, args)
if [ $# -eq 4 ];
then
	exitCodeFile=$2
	command=$3
	args=$4
	
	su -p -c "$command" "$args"
	exitCode=$?

	echo $exitCode>$exitCodeFile
	exit $exitCode
fi
<commit_msg>#6 Support Unix OS - runAs.sh minor<commit_after>#!/bin/bash

#  runAs (settings_file_name, command_file_name, password)
if [ $# -eq 3 ];
then
        args=$(cat "$1")
        command=$2
        password=$3

	exitCodeFile=$(tempfile)
        chmod a+w $exitCodeFile
	cmd="${0} su $exitCodeFile $command $args"

        # run command
        (
		# wait for password input
		attempts=100
		while [[ ! -s $exitCodeFile && attemps -le 0 ]];
		do
			sleep .1;
			attempts=$((attempts-1));
		done

		# send password to su stdIn
		echo "$password"

		# wait for process finish
		while ps axg | grep "su $exitCodeFile" > /dev/null; 
		do
			sleep .1;
		done
	) | (
		# su
		socat - EXEC:"$cmd",pty,ctty,setsid
	) 2> >(tee >"$exitCodeFile" >(grep -v "[Pp]assword:" >&2))

        # if exit file is empty
        if [ ! -s $exitCodeFile ];
        then
                echo "System or authentication failure" >&2
                exit 1
        fi

	# take exid code from file
	exitCode=$(cat "$exitCodeFile")
        rm $exitCodeFile 1> /dev/null 2> /dev/null
        exit $exitCode
fi

# su (su, exit_code_file, command_file_name, args)
if [ $# -eq 4 ];
then
	exitCodeFile=$2
	command=$3
	args=$4

	su -p -c "$command" "$args"
	exitCode=$?

	echo $exitCode>$exitCodeFile
	exit $exitCode
fi

{'fraction_non_alphanumeric': 0.14187271990271585, 'fraction_numerical': 0.018240778273206325, 'mean_word_length': 2.371584699453552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '5162891', 'n_tokens_mistral': 985, 'n_tokens_neox': 895, 'n_words': 253}