dot

packages and services management
Log | Files | Refs | README

commit 969abbede5b526cd2491bd8f439bd4cb422eb4c3
parent 74b45cbf8884b9c6e6da768f220c4c49c113ea51
Author: Josuah Demangeonā  ā µ <mail@josuah.net>
Date:   Sun, 12 Mar 2017 22:45:29 +0100

simplified io-run

Diffstat:
Mbin/io-run | 26+++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/bin/io-run b/bin/io-run @@ -4,36 +4,32 @@ CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" -# update the cache and get the command to run - cache() { - IFS=':' u=0 + IFS=':' - for path in $PATH + [ ! -f "$CACHE/io/run" ] && UPDATE='1' || for path in $PATH do - [ "$CACHE/io/run" -ot "$path" ] && u=1 + [ "$CACHE/io/run" -ot "$path" ] && UPDATE='1' && break done - [ "$u" -eq 1 ] && find . -L $PATH -type f -exec [ -x {} ] \; -print | - sed 's|.*/||' | sort -u | while IFS='' read -r command - do - printf '%-20s ' "$command" - whatis 1 "$command" | sed 's/.* - ' - done < "$CACHE/io/run" + [ "$UPDATE" ] && + find -L . $PATH -maxdepth 1 -type f -exec test -x {} \; -print | + sed 's/.*\///' | sort -u > "$CACHE/io/run" + + unset IFS } main() { mkdir -p "$CACHE/io" - touch "$CACHE/io/run" cache - command="${1:-$($FILTER < "$CACHE/io/run")}" - [ "$command" ] || exit 1 + cmd="${1:-$($FILTER < "$CACHE/io/run")}" + [ "$cmd" ] || exit 1 - exec $command + exec $cmd }