#!/bin/sh
#
# setpython - create a local link from 'python' to a specified version
#
# This script is used to to redirect the 'python' in reposurgeon's
# shebang line to a specified version when running regression tests.

if [ "$1" = python ] || [ "$1" = python2 ] || [ "$1" = python3 ]
then
	p=$(command -v "$1")
	case $p in
	    */bin/*)
		# shellcheck disable=SC2086
		ln -sf "$p" ./python; echo "python -> $p"
		;;
	    *)
		#saved=`readlink ./python 2>/dev/null`
		rm -f ./python
		;;
	esac
else
	echo "setpython: unrecognized python version" >&2
	exit 1
fi
