aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/cpt-owns13
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/cpt-owns b/contrib/cpt-owns
index 60c4633..5f73674 100755
--- a/contrib/cpt-owns
+++ b/contrib/cpt-owns
@@ -3,6 +3,17 @@
case "$1" in ''|--help|-h) printf '%s\n' "usage: ${0##*/} [file]" ; exit 0 ; esac
+# If full path is not specified, use either the current directory, or look for
+# a command.
+case "$1" in /*) ;;
+ *)
+ if [ -f "$1" ]; then
+ set -- "$PWD/$1"
+ else
+ set -- "$(command -v "$1")"
+ fi
+esac
+
# Strip 'CPT_ROOT' from the file path if passed and
# follow symlinks.
file="${1#$CPT_ROOT}"
@@ -27,4 +38,4 @@ pkg_owns=$(grep -lFx "${file#$CPT_ROOT}" \
pkg_owns=${pkg_owns%/*}
pkg_owns=${pkg_owns##*/}
-printf '%s\n' "[$pkg_owns] owns '$1'"
+printf '%s\n' "$pkg_owns"