<commit_before>#!/usr/bin/env bash
#
# brew-install.sh
# Copyright (C) 2013 KuoE0 <<EMAIL>>
#
# Distributed under terms of the MIT license.

function get-package-name {
	echo $(echo $1 | cut -d':' -f1)
}

function get-parameters {
	DEL=$(echo $1 | grep -o ':' | wc -l)
	if [ "$DEL" = "1" ]; then
		echo $(echo $1 | cut -d':' -f2)
	fi
}

function tolower {
	echo $1 | tr '[:upper:]' '[:lower:]' | tr ' ' '-'
}

# create temporal directory & log directory
TMP_DIR=/tmp/BREW-$(date +%Y%m%d-%H%M%S)
LOGDIR="$TMP_DIR/log"
IFS=$'\n'

if [ -d $TMP_DIR ] || [ -f $TMP_DIR ]; then
	rm -r $TMP_DIR
fi
mkdir -p $TMP_DIR
mkdir -p $LOGDIR

# brew does not exist
if ! which brew &> /dev/null; then
	# remove homebrew directory /usr/local/Cellar
	if [ -d /usr/local/Cellar ] || [ -f /usr/local/Cellar ]; then
		rm -rf /usr/local/Cellar
	fi

	# remove homebrew directory /usr/local/.git
	if [ -d /usr/local/.git ] || [ -f /usr/local/.git ]; then
		rm -rf /usr/local/.git
	fi

	# install homebrew
	echo "Install Homebrew..."
	# send ENTER keystroke to install automatically
	echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

fi

# homebrew install failed
if ! which brew &> /dev/null; then
	echo "Homebrew install failed!"
	exit 255
fi

# add taps to homebrew
tap_list=(caskroom/cask caskroom/versions caskroom/fonts homebrew/dupes homebrew/science homebrew/versions)

for TAP_NAME in ${tap_list[*]}; do
	echo "Add tap $TAP_NAME to Homebrew..."
	brew tap $TAP_NAME
done


# brew status check
echo "Diagnose Homebrew..."
brew doctor 2>&1 | tee "$LOGDIR/brew-doctor.log"

# install packages and applications
if [ "$?" = "0" ]; then

	# use llvm to build
	brew --env --use-llvm

	# update brew database
	brew update

	# install & upgrade brew-cask
	brew install brew-cask
	brew upgrade brew-cask

	# install applications from homebrew-cask
	# Install from homebrew-cask first, because there are some package need XQuartz
	while read APP; do
		echo "Installing $APP..."
		PKG=$(tolower $APP)
		brew cask install "$PKG" --appdir=/Applications 2>&1 | tee "$LOGDIR/$PKG.log"
	done < brew-cask.list

	# install packages from homebrew
	while read LINE; do
		PKG=$(get-package-name $LINE)
		PARAM=$(get-parameters $LINE)
		echo "Installing $PKG..."
		brew install "$PKG" "$PARAM" 2>&1 | tee "$LOGDIR/$PKG.log"
	done < brew.list
fi
<commit_msg>remove leading space and trailing space & show package name and parameters when install<commit_after>#!/usr/bin/env bash
#
# brew-install.sh
# Copyright (C) 2013 KuoE0 <<EMAIL>>
#
# Distributed under terms of the MIT license.

function get-package-name {
	echo -e "$1" | cut -d':' -f1 | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
}

function get-parameters {
	CNT=$(echo -e "$1" | grep -o ':' | wc -l)
	if (( $CNT == 1 )); then
		echo -e "$1" | cut -d':' -f2 | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
	fi
}

function tolower {
	echo $1 | tr '[:upper:]' '[:lower:]' | tr ' ' '-'
}

# create temporal directory & log directory
TMP_DIR=/tmp/BREW-$(date +%Y%m%d-%H%M%S)
LOGDIR="$TMP_DIR/log"
IFS=$'\n'

if [ -d $TMP_DIR ] || [ -f $TMP_DIR ]; then
	rm -r $TMP_DIR
fi
mkdir -p $TMP_DIR
mkdir -p $LOGDIR

# brew does not exist
if ! which brew &> /dev/null; then
	# remove homebrew directory /usr/local/Cellar
	if [ -d /usr/local/Cellar ] || [ -f /usr/local/Cellar ]; then
		rm -rf /usr/local/Cellar
	fi

	# remove homebrew directory /usr/local/.git
	if [ -d /usr/local/.git ] || [ -f /usr/local/.git ]; then
		rm -rf /usr/local/.git
	fi

	# install homebrew
	echo "Install Homebrew..."
	# send ENTER keystroke to install automatically
	echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

fi

# homebrew install failed
if ! which brew &> /dev/null; then
	echo "Homebrew install failed!"
	exit 255
fi

# add taps to homebrew
tap_list=(caskroom/cask caskroom/versions caskroom/fonts homebrew/dupes homebrew/science homebrew/versions)

for TAP_NAME in ${tap_list[*]}; do
	echo "Add tap $TAP_NAME to Homebrew..."
	brew tap $TAP_NAME
done


# brew status check
echo "Diagnose Homebrew..."
brew doctor 2>&1 | tee "$LOGDIR/brew-doctor.log"

# install packages and applications
if [ "$?" = "0" ]; then

	# use llvm to build
	brew --env --use-llvm

	# update brew database
	brew update

	# install & upgrade brew-cask
	brew install brew-cask
	brew upgrade brew-cask

	# install applications from homebrew-cask
	# Install from homebrew-cask first, because there are some package need XQuartz
	while read APP; do
		echo "Installing $APP..."
		PKG=$(tolower $APP)
		brew cask install "$PKG" --appdir=/Applications 2>&1 | tee "$LOGDIR/$PKG.log"
	done < brew-cask.list

	# install packages from homebrew
	while read LINE; do
		PKG=$(get-package-name "$LINE")
		PARAM=$(get-parameters "$LINE")
		echo "PKG:   \"$PKG\""
		echo "PARAM: \"$PARAM\""
		bash -c "brew install $PKG $PARAM 2>&1 | tee $LOGDIR/$PKG.log"
	done < brew.list
fi

{'fraction_non_alphanumeric': 0.16168148746968472, 'fraction_numerical': 0.00889248181083266, 'mean_word_length': 3.3757736516357206, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 2, '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': '2919374', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1827, 'n_words': 566}