summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2023-09-08 13:49:16 -0400
committerGitHub <noreply@github.com>2023-09-08 13:49:16 -0400
commit14f248652c077e291112f456efb8026bc880d27d (patch)
tree36df43533b24c2498ccfeba91cb6fe37a5025da8
parent87f99de3fb2d064549db4a156e4f5c33e98e3308 (diff)
downloadspack-14f248652c077e291112f456efb8026bc880d27d.tar.gz
spack-14f248652c077e291112f456efb8026bc880d27d.tar.bz2
spack-14f248652c077e291112f456efb8026bc880d27d.tar.xz
spack-14f248652c077e291112f456efb8026bc880d27d.zip
Spack on Windows: fix shell scripts when root contains a space (#39875)
Enclose variable tracking root in quotes.
-rw-r--r--bin/spack.bat2
-rw-r--r--bin/spack.ps133
2 files changed, 17 insertions, 18 deletions
diff --git a/bin/spack.bat b/bin/spack.bat
index c9afffb51a..b067256cf9 100644
--- a/bin/spack.bat
+++ b/bin/spack.bat
@@ -14,7 +14,7 @@
::
@echo off
-set spack=%SPACK_ROOT%\bin\spack
+set spack="%SPACK_ROOT%"\bin\spack
::#######################################################################
:: This is a wrapper around the spack command that forwards calls to
diff --git a/bin/spack.ps1 b/bin/spack.ps1
index d3f48dfc59..e08f1fc53d 100644
--- a/bin/spack.ps1
+++ b/bin/spack.ps1
@@ -55,10 +55,10 @@ function Set-SpackEnv {
function Invoke-SpackCD {
if (Compare-CommonArgs $SpackSubCommandArgs) {
- python $Env:SPACK_ROOT/bin/spack cd -h
+ python "$Env:SPACK_ROOT/bin/spack" cd -h
}
else {
- $LOC = $(python $Env:SPACK_ROOT/bin/spack location $SpackSubCommandArgs)
+ $LOC = $(python "$Env:SPACK_ROOT/bin/spack" location $SpackSubCommandArgs)
if (($NULL -ne $LOC)){
if ( Test-Path -Path $LOC){
Set-Location $LOC
@@ -75,7 +75,7 @@ function Invoke-SpackCD {
function Invoke-SpackEnv {
if (Compare-CommonArgs $SpackSubCommandArgs[0]) {
- python $Env:SPACK_ROOT/bin/spack env -h
+ python "$Env:SPACK_ROOT/bin/spack" env -h
}
else {
$SubCommandSubCommand = $SpackSubCommandArgs[0]
@@ -83,46 +83,45 @@ function Invoke-SpackEnv {
switch ($SubCommandSubCommand) {
"activate" {
if (Compare-CommonArgs $SubCommandSubCommandArgs) {
- python $Env:SPACK_ROOT/bin/spack env activate $SubCommandSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" env activate $SubCommandSubCommandArgs
}
elseif ([bool]($SubCommandSubCommandArgs.Where({$_ -eq "--pwsh"}))) {
- python $Env:SPACK_ROOT/bin/spack env activate $SubCommandSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" env activate $SubCommandSubCommandArgs
}
elseif (!$SubCommandSubCommandArgs) {
- python $Env:SPACK_ROOT/bin/spack env activate $SubCommandSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" env activate $SubCommandSubCommandArgs
}
else {
- $SpackEnv = $(python $Env:SPACK_ROOT/bin/spack $SpackCMD_params env activate "--pwsh" $SubCommandSubCommandArgs)
+ $SpackEnv = $(python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params env activate "--pwsh" $SubCommandSubCommandArgs)
Set-SpackEnv $SpackEnv
}
}
"deactivate" {
if ([bool]($SubCommandSubCommandArgs.Where({$_ -eq "--pwsh"}))) {
- python $Env:SPACK_ROOT/bin/spack env deactivate $SubCommandSubCommandArgs
+ python"$Env:SPACK_ROOT/bin/spack" env deactivate $SubCommandSubCommandArgs
}
elseif($SubCommandSubCommandArgs) {
- python $Env:SPACK_ROOT/bin/spack env deactivate -h
+ python "$Env:SPACK_ROOT/bin/spack" env deactivate -h
}
else {
- $SpackEnv = $(python $Env:SPACK_ROOT/bin/spack $SpackCMD_params env deactivate "--pwsh")
+ $SpackEnv = $(python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params env deactivate "--pwsh")
Set-SpackEnv $SpackEnv
}
}
- default {python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs}
+ default {python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs}
}
}
}
function Invoke-SpackLoad {
if (Compare-CommonArgs $SpackSubCommandArgs) {
- python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
}
elseif ([bool]($SpackSubCommandArgs.Where({($_ -eq "--pwsh") -or ($_ -eq "--list")}))) {
- python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
}
else {
- # python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand "--pwsh" $SpackSubCommandArgs
- $SpackEnv = $(python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand "--pwsh" $SpackSubCommandArgs)
+ $SpackEnv = $(python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand "--pwsh" $SpackSubCommandArgs)
Set-SpackEnv $SpackEnv
}
}
@@ -131,7 +130,7 @@ function Invoke-SpackLoad {
$SpackCMD_params, $SpackSubCommand, $SpackSubCommandArgs = Read-SpackArgs $args
if (Compare-CommonArgs $SpackCMD_params) {
- python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
+ python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs
exit $LASTEXITCODE
}
@@ -143,5 +142,5 @@ switch($SpackSubCommand)
"env" {Invoke-SpackEnv}
"load" {Invoke-SpackLoad}
"unload" {Invoke-SpackLoad}
- default {python $Env:SPACK_ROOT/bin/spack $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs}
+ default {python "$Env:SPACK_ROOT/bin/spack" $SpackCMD_params $SpackSubCommand $SpackSubCommandArgs}
}