kiss/contrib/kiss-fork
2020-09-04 13:32:19 -04:00

28 lines
634 B
Bash
Executable File

#!/bin/sh -ef
# Copy a package's repository files into the current directory
# Ignore shellcheck as we want the warning's behavior.
# shellcheck disable=2015
[ "$1" ] && kiss search "${1:-null}" >/dev/null || {
printf 'usage: [kiss-fork [pkg]] [index]\n'
exit 1
}
num=$2
# Disable this warning as globbing is disabled and word splitting
# is intentional. This grabs the location of the package's files.
# shellcheck disable=2046
(
set -- $(kiss search "$1")
shift "${num:-0}"
[ -d "$1" ] && {
printf 'found package in %s\n' "$1"
cp -r "$1" .
}
)
printf 'forked package to %s\n' "$PWD/$1"