diff options
Diffstat (limited to 'folders.sh')
-rwxr-xr-x | folders.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/folders.sh b/folders.sh new file mode 100755 index 000000000..0a3fcfc90 --- /dev/null +++ b/folders.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +function PKG_DATA_() { + echo "${PKG_BASE}/data/$1" +} + +export -f PKG_DATA_ + +function PKG_WORK_() { + echo "${PKG_BASE}/work/${PKG_TARG}/$1" +} + +export -f PKG_WORK_ + +function PKG_DEST_() { + echo "${PKG_BASE}/dest/${PKG_TARG}/$1" +} + +export -f PKG_DEST_ + +function pkg_ { + case "${1:0:1}" in + (/) echo "${PKG_DEST}$1";; + (%) echo "${PKG_DATA}${1:1}";; + (*) echo -"$1" | sed -e 's/^.//';; + esac +} + +export -f pkg_ + +function pkg: { + declare -a argv + declare argc=$# + + for ((i=0; $i != $argc; ++i)); do + argv[$i]=$(pkg_ "$1") + shift + done + + "${argv[@]}" +} + +export -f pkg: |