#!/bin/bash

## usage
USAGE="USAGE:
$(basename "$0") source_file dest_dir"
readonly USAGE

function help_message() {
  printf "%s\n" "$USAGE"
}

## check parameters
if [ "$#" -ne 2 ]; then
  help_message
  exit 0
fi

## vars
SOURCE=$1
readonly SOURCE

TARGET="$(
  cd -- "$2" >/dev/null 2>&1 || exit
  pwd -P
)"
readonly TARGET

## test vars
if ! test -f "${SOURCE}"; then
  exit 0
fi

if ! test -d "${TARGET}"; then
  exit 0
fi

## create link
ln -s "${SOURCE}" "${TARGET}"/"$(basename "${SOURCE}")"
