kiss/contrib/kiss-fork

31 lines
600 B
Plaintext
Raw Normal View History

2020-03-13 07:43:54 -06:00
#!/bin/sh -ef
2020-05-01 00:07:20 -06:00
# Copy a package's repository files into the current directory
2020-03-13 07:43:54 -06:00
2020-09-09 04:58:00 -06:00
pkg=${1:-"${PWD##*/}"}
num=$(printf %d "${2:-0}")
dir=$(kiss search "$pkg" 2>/dev/null) || {
printf 'usage: [kiss-fork [pkg]] [index]\n'
2020-03-13 07:43:54 -06:00
exit 1
}
2020-11-19 00:53:51 -07:00
# Globbing is disabled and word splitting is intentional.
2020-09-09 04:58:00 -06:00
# shellcheck disable=2086
set -- $dir
2020-09-09 04:58:00 -06:00
[ "$num" -ge "$#" ] && {
printf 'index exceeds maximum\n'
2020-11-19 00:53:51 -07:00
exit 1
2020-09-09 04:58:00 -06:00
}
2020-03-13 07:43:54 -06:00
2020-09-09 04:58:00 -06:00
shift "$num"
2020-09-09 04:58:00 -06:00
[ "$1" ] || [ -d "$1" ] || {
printf 'failed to locate package\n'
exit 1
}
2020-03-13 07:43:54 -06:00
2020-09-09 04:58:00 -06:00
printf 'found package in %s\n' "$1"
2020-11-19 00:53:51 -07:00
cp -Lrf "$1" .
2020-09-09 04:58:00 -06:00
printf 'forked package to %s\n' "$PWD/$pkg"