<commit_before>#!/bin/bash

## ================================================================
## Logtalk - Open source object-oriented logic programming language
## Release 2.37.1
## 
## Copyright (c) 1998-2009 <NAME>.        All Rights Reserved.
## Logtalk is free software.  You can redistribute it and/or modify
## it under the terms of the "Artistic License 2.0" as published by 
## The Perl Foundation. Consult the "LICENSE.txt" file for details.
## ================================================================


print_version() {
	echo "`basename $0` 0.2"
	exit 1
}


list_versions() {
    echo -n "Available versions: "
	for path in $(ls -d "$prefix"/lgt*); do
		file=`basename $path`
		if [ $file \> "lgt2351" ]; then
			echo -n "$file "
		fi
	done
	echo
	exit 1
}


show_selected() {
    echo -n "Current version: "
    if [ -e "$LOGTALKHOME" ]; then
		readlink "$LOGTALKHOME"
    else
        echo "none"
    fi
	exit 1
}


usage_help() {
	echo 
	echo "This script allows switching between installed Logtalk versions"
	echo
	echo "Usage:"
	echo "  `basename $0` [-vlsh] version"
	echo
	echo "Optional arguments:"
	echo "  -v print version of `basename $0`"
	echo "  -l list available versions"
	echo "  -s show the currently selected version"
	echo "  -h help"
	echo
	exit 1
}


valid_version() {
    for path in $(ls -d "$prefix"/lgt*); do
		version=`basename $path`
        if [ $1 == $version -a $1 \> "lgt2351" ]; then
            return 0
        fi
    done
    return 1
}


switch_version() {
	valid_version $1
	if [ 0 != ${?} ]; then
    	echo "Invalid version: \"$1\"!"
    	exit 1
	else
		cd "$prefix"
		rm -f logtalk
		ln -sf $1 logtalk
		exit 0
	fi
}


while getopts "vlsh" Option
do
	case $Option in
		v) print_version;;
		l) list_versions;;
		s) show_selected;;
		h) usage_help;;
		*) usage_help;;
	esac
done


if ! [ "$LOGTALKHOME" ]; then
	echo "The environment variable LOGTALKHOME should be defined first, pointing"
	echo "to your Logtalk installation directory!"
	echo "Trying the default locations for the Logtalk installation..."
	if [ -d "/usr/local/share/logtalk" ]; then
		LOGTALKHOME=/usr/local/share/logtalk
		echo "... using Logtalk installation found at /usr/local/share/logtalk"
	elif [ -d "/usr/share/logtalk" ]; then
		LOGTALKHOME=/usr/share/logtalk
		echo "... using Logtalk installation found at /usr/share/logtalk"
	elif [ -d "/opt/local/share/logtalk" ]; then
		LOGTALKHOME=/opt/local/share/logtalk
		echo "... using Logtalk installation found at /opt/local/share/logtalk"
	elif [ -d "/opt/share/logtalk" ]; then
		LOGTALKHOME=/opt/share/logtalk
		echo "... using Logtalk installation found at /opt/share/logtalk"
	else
		echo "... unable to locate Logtalk installation directory!"
		echo
		exit 1
	fi
	echo
elif ! [ -d "$LOGTALKHOME" ]; then
	echo "The environment variable LOGTALKHOME points to a non-existing directory!"
	echo "Its current value is: $LOGTALKHOME"
	echo "The variable must be set to your Logtalk installation directory!"
	echo
	exit 1
fi
export LOGTALKHOME

prefix=`dirname "$LOGTALKHOME"`


if [ "$1" == "" ]; then
	usage_help
else
	switch_version $1
	error=$?
	if [ 0 != $error ]; then
		echo "An error occurred when activating version \"$version\"!"
		exit 1
	fi
	exit 0
fi
<commit_msg>Updated the experimental "logtalk_select.sh" POSIX shell script for switching between installed Logtalk versions to require version 2.36.0 or later.<commit_after>#!/bin/bash

## ================================================================
## Logtalk - Open source object-oriented logic programming language
## Release 2.37.1
## 
## Copyright (c) 1998-2009 <NAME>.        All Rights Reserved.
## Logtalk is free software.  You can redistribute it and/or modify
## it under the terms of the "Artistic License 2.0" as published by 
## The Perl Foundation. Consult the "LICENSE.txt" file for details.
## ================================================================


print_version() {
	echo "`basename $0` 0.2"
	exit 1
}


list_versions() {
    echo -n "Available versions: "
	for path in $(ls -d "$prefix"/lgt*); do
		file=`basename $path`
		if [ $file \> "lgt2351" ]; then
			echo -n "$file "
		fi
	done
	echo
	exit 1
}


show_selected() {
    echo -n "Current version: "
    if [ -e "$LOGTALKHOME" ]; then
		readlink "$LOGTALKHOME"
    else
        echo "none"
    fi
	exit 1
}


usage_help() {
	echo 
	echo "This script allows switching between installed Logtalk versions"
	echo
	echo "Usage:"
	echo "  `basename $0` [-vlsh] version"
	echo
	echo "Optional arguments:"
	echo "  -v print version of `basename $0`"
	echo "  -l list available versions"
	echo "  -s show the currently selected version"
	echo "  -h help"
	echo
	exit 1
}


valid_version() {
    for path in $(ls -d "$prefix"/lgt*); do
		version=`basename $path`
        if [ $1 == $version -a $1 \> "lgt2351" ]; then
            return 0
        fi
    done
    return 1
}


switch_version() {
	valid_version $1
	if [ 0 != ${?} ]; then
    	echo "Invalid version: \"$1\"!"
    	exit 1
	else
		cd "$prefix"
		rm -f logtalk
		ln -sf $1 logtalk
		exit 0
	fi
}


if ! [ "$LOGTALKHOME" ]; then
	echo "The environment variable LOGTALKHOME should be defined first, pointing"
	echo "to your Logtalk installation directory!"
	echo "Trying the default locations for the Logtalk installation..."
	if [ -d "/usr/local/share/logtalk" ]; then
		LOGTALKHOME=/usr/local/share/logtalk
		echo "... using Logtalk installation found at /usr/local/share/logtalk"
	elif [ -d "/usr/share/logtalk" ]; then
		LOGTALKHOME=/usr/share/logtalk
		echo "... using Logtalk installation found at /usr/share/logtalk"
	elif [ -d "/opt/local/share/logtalk" ]; then
		LOGTALKHOME=/opt/local/share/logtalk
		echo "... using Logtalk installation found at /opt/local/share/logtalk"
	elif [ -d "/opt/share/logtalk" ]; then
		LOGTALKHOME=/opt/share/logtalk
		echo "... using Logtalk installation found at /opt/share/logtalk"
	else
		echo "... unable to locate Logtalk installation directory!"
		echo
		exit 1
	fi
	echo
elif ! [ -d "$LOGTALKHOME" ]; then
	echo "The environment variable LOGTALKHOME points to a non-existing directory!"
	echo "Its current value is: $LOGTALKHOME"
	echo "The variable must be set to your Logtalk installation directory!"
	echo
	exit 1
fi
export LOGTALKHOME=$LOGTALKHOME


prefix=`dirname "$LOGTALKHOME"`


while getopts "vlsh" Option
do
	case $Option in
		v) print_version;;
		l) list_versions;;
		s) show_selected;;
		h) usage_help;;
		*) usage_help;;
	esac
done


if [ "$1" == "" ]; then
	usage_help
else
	switch_version $1
	error=$?
	if [ 0 != $error ]; then
		echo "An error occurred when activating version \"$version\"!"
		exit 1
	fi
	exit 0
fi

{'fraction_non_alphanumeric': 0.1568921553922304, 'fraction_numerical': 0.014999250037498125, 'mean_word_length': 3.313065976714101, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3069255', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2173, 'n_words': 752}