diff mbox series

toolchain-scripts: fix tree env script restoring caller's cwd

Message ID 20260811143343.36011-1-alessandro.zini@siemens.com
State Under Review
Headers show
Series toolchain-scripts: fix tree env script restoring caller's cwd | expand

Commit Message

Alessandro Zini Aug. 11, 2026, 2:33 p.m. UTC
Backticks inside double quotes are expanded at build time, so the
generated script always cd's back to COREBASE rather than to the
directory the user was in when they sourced the script.

Replace with a (correctly escaped) $(pwd).

Signed-off-by: Alessandro Zini <alessandro.zini@siemens.com>
---
 meta/classes-recipe/toolchain-scripts.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/toolchain-scripts.bbclass b/meta/classes-recipe/toolchain-scripts.bbclass
index ab526c31f6..a4e8d3aa9b 100644
--- a/meta/classes-recipe/toolchain-scripts.bbclass
+++ b/meta/classes-recipe/toolchain-scripts.bbclass
@@ -96,7 +96,7 @@  toolchain_create_tree_env_script () {
 	touch $script
 	echo 'standalone_sysroot_target="${STAGING_DIR}/${MACHINE}"' >> $script
 	echo 'standalone_sysroot_native="${STAGING_DIR}/${BUILD_ARCH}"' >> $script
-	echo "orig=`pwd`; cd ${COREBASE}; set ${TOPDIR} $bitbakedir; . ./oe-init-build-env; cd \$orig" >> $script
+	echo "orig=\$(pwd); cd ${COREBASE}; set ${TOPDIR} $bitbakedir; . ./oe-init-build-env; cd \$orig" >> $script
 	echo 'export PATH=$standalone_sysroot_native/${bindir_native}:$standalone_sysroot_native/${bindir_native}/${TARGET_SYS}:$PATH' >> $script
 	echo 'export PKG_CONFIG_SYSROOT_DIR=$standalone_sysroot_target' >> $script
 	echo 'export PKG_CONFIG_PATH=$standalone_sysroot_target'"$libdir"'/pkgconfig:$standalone_sysroot_target'"$prefix"'/share/pkgconfig' >> $script