1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-24 16:10:05 -07:00
kiss/contrib/kiss-fork
2020-11-19 09:53:51 +02:00

31 lines
600 B
Bash
Executable File

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