~ecs/tm

530f55bc933996c2c43b955b9e589ad40ab24c87 — Ember Sawady 3 years ago d53ea09
resolve-path: fix usage
1 files changed, 3 insertions(+), 6 deletions(-)

M tm-resolve-path
M tm-resolve-path => tm-resolve-path +3 -6
@@ 1,8 1,6 @@
#!/bin/sh -eu

usage() {
	abort "usage: tm resolve-path [-f <field>] <tree> <path>"
}
. "$(dirname -- "$0")/lib.sh"

field=2
while getopts f: opt; do


@@ 24,15 22,14 @@ while getopts f: opt; do
		esac
		;;
	?)
		usage
		abort "usage: tm resolve-path [-f <field>] <tree> <path>"
		;;
	esac
done

shift "$((OPTIND - 1))"

. "$(dirname -- "$0")/lib.sh"
[ $# -ne 2 ] && usage
[ $# -ne 2 ] &&  abort "usage: tm resolve-path [-f <field>] <tree> <path>"
ref="$(tm resolve-ref "$1")" || abort "error: invalid ref $1"
[ "z$2" = "z/" ] || [ "z$2" = "z." ] && printf "%s\n" "$ref" && exit
dirref="$(tm resolve-path -- "$1" "$(dirname -- "$2")")"