Skip to content

Commit 08b948c

Browse files
committed
* fixed filepath_contains_filepath for the '.' directory where foo.sh now matches
1 parent 7cf7004 commit 08b948c

7 files changed

+141
-61
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required (VERSION 3.13)
22

3-
project( mulle-bashfunctions VERSION 6.6.0 LANGUAGES NONE)
3+
project( mulle-bashfunctions VERSION 6.6.1 LANGUAGES NONE)
44

55

66
#

mulle-bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fi
151151
# this is "our" version
152152
# the actual loaded version may differ (and will change this variable)
153153
#
154-
MULLE_BASHFUNCTIONS_VERSION="6.6.0"
154+
MULLE_BASHFUNCTIONS_VERSION="6.6.1"
155155
MULLE_BASHFUNCTIONS_LIBEXEC_DIRNAME="libexec"
156156
MULLE_EXECUTABLE="$1"
157157

src/mulle-bashfunctions-all-embed.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,19 +3458,35 @@ function r_assert_sane_path()
34583458

34593459
filepath_contains_filepath()
34603460
{
3461-
local string1="${1%/}" # Path to check, remove trailing slash
3462-
local string2="${2%/}" # Directory path, remove trailing slash
3461+
local filepath="${1%/}" # Path to check, remove trailing slash
3462+
local other="${2%/}" # Directory path, remove trailing slash
34633463

3464-
case "${string2}" in
3465-
${string1})
3466-
return 0
3467-
;;
3468-
${string1}/*)
3469-
return 0
3470-
;;
3471-
*)
3464+
r_simplified_path "${filepath}"
3465+
filepath="${RVAL}"
3466+
3467+
r_simplified_path "${other}"
3468+
RVAL=${RVAL}
3469+
3470+
case "${filepath}" in
3471+
.)
3472+
if is_absolutepath "${other}"
3473+
then
34723474
return 1
3473-
;;
3475+
fi
3476+
return 0
3477+
;;
3478+
esac
3479+
3480+
case "${other}" in
3481+
${filepath})
3482+
return 0
3483+
;;
3484+
${filepath}/*)
3485+
return 0
3486+
;;
3487+
*)
3488+
return 1
3489+
;;
34743490
esac
34753491
}
34763492

src/mulle-bashfunctions-all.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,19 +3641,35 @@ function r_assert_sane_path()
36413641

36423642
filepath_contains_filepath()
36433643
{
3644-
local string1="${1%/}" # Path to check, remove trailing slash
3645-
local string2="${2%/}" # Directory path, remove trailing slash
3644+
local filepath="${1%/}" # Path to check, remove trailing slash
3645+
local other="${2%/}" # Directory path, remove trailing slash
36463646

3647-
case "${string2}" in
3648-
${string1})
3649-
return 0
3650-
;;
3651-
${string1}/*)
3652-
return 0
3653-
;;
3654-
*)
3647+
r_simplified_path "${filepath}"
3648+
filepath="${RVAL}"
3649+
3650+
r_simplified_path "${other}"
3651+
RVAL=${RVAL}
3652+
3653+
case "${filepath}" in
3654+
.)
3655+
if is_absolutepath "${other}"
3656+
then
36553657
return 1
3656-
;;
3658+
fi
3659+
return 0
3660+
;;
3661+
esac
3662+
3663+
case "${other}" in
3664+
${filepath})
3665+
return 0
3666+
;;
3667+
${filepath}/*)
3668+
return 0
3669+
;;
3670+
*)
3671+
return 1
3672+
;;
36573673
esac
36583674
}
36593675

src/mulle-bashfunctions-embed.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,19 +3458,35 @@ function r_assert_sane_path()
34583458

34593459
filepath_contains_filepath()
34603460
{
3461-
local string1="${1%/}" # Path to check, remove trailing slash
3462-
local string2="${2%/}" # Directory path, remove trailing slash
3461+
local filepath="${1%/}" # Path to check, remove trailing slash
3462+
local other="${2%/}" # Directory path, remove trailing slash
34633463

3464-
case "${string2}" in
3465-
${string1})
3466-
return 0
3467-
;;
3468-
${string1}/*)
3469-
return 0
3470-
;;
3471-
*)
3464+
r_simplified_path "${filepath}"
3465+
filepath="${RVAL}"
3466+
3467+
r_simplified_path "${other}"
3468+
RVAL=${RVAL}
3469+
3470+
case "${filepath}" in
3471+
.)
3472+
if is_absolutepath "${other}"
3473+
then
34723474
return 1
3473-
;;
3475+
fi
3476+
return 0
3477+
;;
3478+
esac
3479+
3480+
case "${other}" in
3481+
${filepath})
3482+
return 0
3483+
;;
3484+
${filepath}/*)
3485+
return 0
3486+
;;
3487+
*)
3488+
return 1
3489+
;;
34743490
esac
34753491
}
34763492

src/mulle-bashfunctions.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,19 +3641,35 @@ function r_assert_sane_path()
36413641

36423642
filepath_contains_filepath()
36433643
{
3644-
local string1="${1%/}" # Path to check, remove trailing slash
3645-
local string2="${2%/}" # Directory path, remove trailing slash
3644+
local filepath="${1%/}" # Path to check, remove trailing slash
3645+
local other="${2%/}" # Directory path, remove trailing slash
36463646

3647-
case "${string2}" in
3648-
${string1})
3649-
return 0
3650-
;;
3651-
${string1}/*)
3652-
return 0
3653-
;;
3654-
*)
3647+
r_simplified_path "${filepath}"
3648+
filepath="${RVAL}"
3649+
3650+
r_simplified_path "${other}"
3651+
RVAL=${RVAL}
3652+
3653+
case "${filepath}" in
3654+
.)
3655+
if is_absolutepath "${other}"
3656+
then
36553657
return 1
3656-
;;
3658+
fi
3659+
return 0
3660+
;;
3661+
esac
3662+
3663+
case "${other}" in
3664+
${filepath})
3665+
return 0
3666+
;;
3667+
${filepath}/*)
3668+
return 0
3669+
;;
3670+
*)
3671+
return 1
3672+
;;
36573673
esac
36583674
}
36593675

src/mulle-path.sh

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -827,26 +827,42 @@ function r_assert_sane_path()
827827
# filepath_contains_filepath <filepath> <other>
828828
#
829829
# Check if <other> is identical to <filepath> or a plausible file or
830-
# subdirectoy. This is just string matching!
830+
# subdirectory. This is just string matching! No filesystem checks
831831
#
832832
filepath_contains_filepath()
833833
{
834-
local string1="${1%/}" # Path to check, remove trailing slash
835-
local string2="${2%/}" # Directory path, remove trailing slash
834+
local filepath="${1%/}" # Path to check, remove trailing slash
835+
local other="${2%/}" # Directory path, remove trailing slash
836836

837-
case "${string2}" in
838-
# Case 1: Strings are identical
839-
${string1})
840-
return 0
841-
;;
842-
# Case 2: string1 is a subdirectory or file inside string2
843-
${string1}/*)
844-
return 0
845-
;;
846-
# Not a match
847-
*)
837+
r_simplified_path "${filepath}"
838+
filepath="${RVAL}"
839+
840+
r_simplified_path "${other}"
841+
RVAL=${RVAL}
842+
843+
case "${filepath}" in
844+
.)
845+
if is_absolutepath "${other}"
846+
then
848847
return 1
849-
;;
848+
fi
849+
return 0
850+
;;
851+
esac
852+
853+
case "${other}" in
854+
# Case 1: Strings are identical
855+
${filepath})
856+
return 0
857+
;;
858+
# Case 2: string1 is a subdirectory or file inside other
859+
${filepath}/*)
860+
return 0
861+
;;
862+
# Not a match
863+
*)
864+
return 1
865+
;;
850866
esac
851867
}
852868

0 commit comments

Comments
 (0)