https://github.com/HazyResearch/deepdive
Raw File
Tip revision: a10d96a09e4593326d44846aa3b59579adefecf6 authored by Jaeho Shin on 05 July 2016, 18:29:45 UTC
Merge branch 'master' of https://github.com/HazyResearch/deepdive into pgtsv-unicode
Tip revision: a10d96a
deepdive-whereis
#!/usr/bin/env bash
# deepdive-whereis -- Finds absolute paths to files in the app or DeepDive installation
# > deepdive whereis FILE...
# > deepdive whereis app FILE...
# > deepdive whereis installed FILE...
##
set -eu

# determine path prefixes to resolve relative paths against
prefixes=() where=
case $1 in
    app)
        shift
        DEEPDIVE_APP=$(find-deepdive-app)
        prefixes+=("$DEEPDIVE_APP/")
        where+=" or the current DeepDive app"
        ;;
    installed)
        shift
        prefixes+=("$DEEPDIVE_HOME/")
        where+=" or DeepDive installation"
        ;;
    *)
        # by default search the app, then the installation
        if DEEPDIVE_APP=$(find-deepdive-app) &>/dev/null; then
            prefixes+=("$DEEPDIVE_APP/")
            where+=" or the current DeepDive app"
        fi
        prefixes+=("$DEEPDIVE_HOME/")
        where+=" or DeepDive installation"
esac
where=${where# or }
[[ $# -gt 0 ]] || usage "$0" "Missing FILE"

# resolve absolute paths
for f; do
    found=false
    for p in "${prefixes[@]}"; do
        [[ -e "$p$f" ]] || continue
        echo "$p$f"
        found=true
    done
    $found || error "$f: No such file in $where"
done
back to top