Project

General

Profile

« Previous | Next » 

Revision 14709

lib/sh/util.sh: canon_rel_path(): fall back to original path if can't resolve, instead of errexiting

View differences:

trunk/lib/sh/util.sh
726 726
# do before setting $top_script_abs so realpath has less symlinks to resolve
727 727

  
728 728
canon_rel_path() # usage: [base_dir=...] canon_rel_path path
729
# falls back to original path if can't resolve
729 730
{
730 731
	kw_params base_dir; local path="$1" base_dir="${base_dir-$PWD}"
732
	canon_rel_path__try || echo "$path"
733
}
734
canon_rel_path__try()
735
{
736
	ensure_nested_func
731 737
	base_dir="$(realpath "$base_dir")" || return
732 738
	path="$(realpath "$path")" || return
733 739
	rel_path

Also available in: Unified diff