mirror of
https://codeberg.org/kiss-community/kiss
synced 2024-11-13 18:25:17 -07:00
31 lines
600 B
Bash
Executable File
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"
|