Project

General

Profile

« Previous | Next » 

Revision 9240

lib/sh/util.sh: moved paths section after logging so it can use logging functions

View differences:

util.sh
152 152
}
153 153

  
154 154

  
155
#### paths
156

  
157
canon_rel_path()
158
{
159
	local path="$1"
160
	path="$(realpath "$path")" # canonicalize
161
	path="${path#$(pwd -P)/}" # remove any shared prefix with the current dir
162
	echo "$path"
163
}
164

  
165
# makes $1 a canon_rel_path if it's a filesystem path
166
alias cmd2rel_path="$(cat <<'EOF'
167
if test "$(type -t "$1")" = file && test -e "$1"; then # not relative to PATH
168
	declare _1="$1"; shift
169
	set -- "$(canon_rel_path "$_1")" "$@"
170
fi
171
EOF
172
)"
173

  
174

  
175 155
#### verbose output
176 156

  
177 157

  
......
258 238
}
259 239

  
260 240

  
241
#### paths
242

  
243
canon_rel_path()
244
{
245
	local path="$1"
246
	path="$(realpath "$path")" # canonicalize
247
	path="${path#$(pwd -P)/}" # remove any shared prefix with the current dir
248
	echo "$path"
249
}
250

  
251
# makes $1 a canon_rel_path if it's a filesystem path
252
alias cmd2rel_path="$(cat <<'EOF'
253
if test "$(type -t "$1")" = file && test -e "$1"; then # not relative to PATH
254
	declare _1="$1"; shift
255
	set -- "$(canon_rel_path "$_1")" "$@"
256
fi
257
EOF
258
)"
259

  
260

  
261
#### verbose output
262

  
263

  
261 264
### command echoing
262 265

  
263 266
alias echo_params='log "$*"'

Also available in: Unified diff