#!/bin/bash
# Usage in Pandoctools profiles:
#   . "$source" script
#   ($source contains absolute path)
# General usage:
#   . source-from-path script

# Calls script ONLY from $PATH
# In order to call script from CWD use: source ./script

full_path="$(type -p "$1")"
all_but_first="${@:2}"


if [[ -f "${full_path}" ]]; then
    source "${full_path}" "${all_but_first}"
else
    echo "Error: $1 was not found in \$PATH or is not a file." >&2
    exit 1
fi
