kiss/contrib/kiss-fork

31 lines
600 B
Plaintext
Raw Normal View History

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