How to pass the output of a powershell function as an argument to a command?
I was unsuccessful with what I thought was a very straightforward command:
git checkout -b SimplifyName("Test 1")
output is an error:
fatal: 'Test 1' is not a commit and a branch 'SimplifyName' cannot be created from it
where, for the sake of this question,
function SimplifyName ([string] $str = "UNDEFINED") {
$result = $str.Trim().ToLowerInvariant() -replace "[^a-z0-9]+","_"
Write-Output $result
}
From what I understand, anything that follows -b is taken as space-delimited string arguments for the git checkout -b command.
I am struggling to find a good help resource for this too since I am possibly using incorrect terminology.
git checkout -b $(SimplifyName("Test 1"))may be all you need...