#!/bin/sh

GETENV="/usr/lib/libelektraintercept-env.so"

if [ ! -f "$GETENV" ]
then
	echo "You do not have $GETENV installed"  1>&2
	echo "Maybe your system is not supported (currently needs to be glibc-based)"  1>&2
	exit 1
fi

# so that kdb elektrify-getenv getenv works!
export PATH="/usr/lib/elektra/tool_exec:$PATH"

if [ "$#" -eq 0 ]
then
	echo "Usage: kdb elektrify-getenv <application> <arguments>"
	echo "For help run kdb elektrify-getenv <application> --elektra-help"
	echo "Path to library is:"
	echo "$GETENV"
else
	LD_PRELOAD="$GETENV" $*
fi
