Add a script for running bash from powershell

This commit is contained in:
Manuel Thalmann 2024-03-20 21:44:02 +01:00
parent 654370f4f0
commit ea1078e5db
2 changed files with 18 additions and 14 deletions

View file

@ -0,0 +1,14 @@
function Start-BashScript() {
param(
[Parameter(Mandatory=$true, Position=0)]
[string[]]$Content
)
Write-Information "Preparing setup script";
$script = New-TemporaryFile;
$script = Rename-Item $script -NewName "$script.sh" -PassThru;
Set-Content $script ([string]::Join("`n", $Content));
Write-Information "Running prepared script";
Start-Process -Wait $script;
Remove-Item $script;
}

View file

@ -1,25 +1,15 @@
#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/Context.ps1";
. "$PSScriptRoot/../../Scripts/BashScript.ps1";
$null = New-Module {
function Backup-Git([Context] $context) {}
function Restore-Git([Context] $context) {
Write-Host "Restoring git";
$script = New-TemporaryFile;
$script = Rename-Item $script "$($script.Name).sh" -PassThru;
Write-Information "Preparing setup script";
Set-Content $script (
[string]::Join(
"`n",
@(
"bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"",
"rm ~/.bashrc")));
Write-Information "Running prepared script";
Start-Process -Wait $script;
Remove-Item $script;
Start-BashScript @(
"bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"",
"rm ~/.bashrc");
}
}