diff mbox series

configure: Use -ef to compare paths

Message ID 20241111-p-v1-1-001006c68b7e@daynix.com (mailing list archive)
State New
Headers show
Series configure: Use -ef to compare paths | expand

Commit Message

Akihiko Odaki Nov. 11, 2024, 7:19 a.m. UTC
configure checks if it is executed in the source directory by comparing
the literal paths, but there may be multiple representations of a
directory due to symbolic links. Use the -ef operator to tell if they
point to the same directory.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 7e3b6d8063f245d27eecce5aabe624b5785f2a77
change-id: 20241111-p-c8a0d3e7fc82

Best regards,

Comments

Thomas Huth Nov. 11, 2024, 7:50 a.m. UTC | #1
On 11/11/2024 08.19, Akihiko Odaki wrote:
> configure checks if it is executed in the source directory by comparing
> the literal paths, but there may be multiple representations of a
> directory due to symbolic links. Use the -ef operator to tell if they
> point to the same directory.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>   configure | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index aa7aae70fa1b..853fa0b81f70 100755
> --- a/configure
> +++ b/configure
> @@ -13,7 +13,7 @@ export CCACHE_RECACHE=yes
>   # make source path absolute
>   source_path=$(cd "$(dirname -- "$0")"; pwd)
>   
> -if test "$PWD" = "$source_path"
> +if test "$PWD" -ef "$source_path"
>   then
>       echo "Using './build' as the directory for build output"

Looking at 
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html it 
sounds like "-ef" is not part of all posix compliant shells? Did you check 
whether it is working with all of our destination host types?

  Thomas
diff mbox series

Patch

diff --git a/configure b/configure
index aa7aae70fa1b..853fa0b81f70 100755
--- a/configure
+++ b/configure
@@ -13,7 +13,7 @@  export CCACHE_RECACHE=yes
 # make source path absolute
 source_path=$(cd "$(dirname -- "$0")"; pwd)
 
-if test "$PWD" = "$source_path"
+if test "$PWD" -ef "$source_path"
 then
     echo "Using './build' as the directory for build output"