/usr/lib/cruft/common.sh is in cruft-common 0.9.34.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # this function is called by all the scripts in explain/
# but only really useful when called from main cruft pgm
cruft_debug(){
:
}
debug()
{
if [ -z "$CRUFT_DEBUG" ] ; then return ; fi
echo "$(date +">[%Y-%m-%d %H:%M:%S.%N] [0]")" "$@" >&2
}
# Checks whether a dir is a subdir of another
# usage:
# is_subdir potential_base potential_subdir
# 0 = success ; if potential_subdir is a subdir of potential_base or they are the same
# 1 = failure ; otherwise
is_subdir()
{
local dir="$1";shift
local sub="$1";shift
# remove trailing slash, unless the dir is root dir itself
[ / != "$dir" ] && dir="${dir%/}"
[ / != "$sub" ] && sub="${sub%/}"
# $sub is the same as $dir
[ "$dir" = "$sub" ] && return 0
# / - special cases, which would need special treatment below
# every dir is a subdir of /
[ / = "$dir" ] && return 0
# no dir is parent of / (except for itself, but that was caught above)
[ / = "$sub" ] && return 1
# try to remove $dir from beginning of $sub
local trail="${sub##$dir}"
if [ "$sub" = "$trail" ] ; then
# since stripping did not succeed (no change)
# then $sub does not begin with $dir
return 1
else
# $sub begins with $dir
# There are two possibilities
if [ "${trail##/}" != "$trail" ] ; then
# $tail begins with a slash
# /dir/sub
return 0
else
# $tail does not begin with slash, so it is not below $dir
# /diranother/sub
return 1
fi
fi
}
get_ignores()
{
:
}
cruft_find()
{
# stub
find "$@"
}
|