#!/usr/bin/env bash
# Simple program that changes ownership to the current
# user, recursively.

LD_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source

if [[ -z "$1" ]]; then
  echo "$LD_BIN: Quickly take ownership of files/folders."
  echo "Usage: $LD_BIN <folders or files>"
  echo "Requires sudo. If sudo is not installed, this tool will fail."
  exit 2
fi

# Ensure all arguments exist before attempting chown
for target in "$@"; do
  if [[ ! -e "$target" ]]; then
    echo "Error: \"$target\" does not exist."
    exit 1
  fi
done

sudo chown -R "$(whoami):$(whoami)" "$@"
