cpt-exec (493B)
1 #!/bin/sh 2 # Execute a command inside the alternatives system 3 4 usage() { 5 printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg] [command]" 6 exit "$1" 7 } 8 9 case "$1" in ''|--help|-h) usage 0; esac 10 [ "$2" ] || usage 1 11 12 pkg=$1 13 14 [ "${2##/*}" ] && command=">usr>bin>$2" || 15 command="$(printf '%s' "$2" | sed 's#/#>#g')" 16 17 [ -h "${file:=/var/db/cpt/choices/$pkg$command}" ] && { 18 printf 'ERROR: %s\n' "$file is a symlink" 19 exit 1 20 } 21 22 shift 2 23 exec "/var/db/cpt/choices/$pkg$command" "$@"