0

I make a function (function sword($href,$username,$path){} which 3 parameters, but the last one parameter ($path) value is 0 ("") at the function begining. The variable is definitly not zero! I checked before the function.

function convertToLinuxPath($path){...return $path}

function sword($href,$username,$path){

    Write-Host $path     #The path has not value here!!! Why???

    $href = $href.replace("otherString","anotherString")
    $bashFile = "/mnt/c/...xy.sh"
    Write-Host $path
    #wsl --exec $bashFile $href $dest
}
$link = Read-Host
$username = Read-Host

$folder = Read-Host
$path = convertToLinuxPath($folder) #This is another function
Write-Host $path #The $path has it value, here!!!
sword($link,$username,$path)

I tried convert to String, but i havent more idea.

  • 1
    [PowerShell Gotcha #2](https://stackoverflow.com/a/69644807/1701026) – iRon Jan 26 '23 at 10:21
  • are you taking the `$path` from the above function i.e. convertToLinuxPath, if so assign a new value to the return of the function, like `$my_path = convertToLinuxPath()` use this value in next function instead – whiteheart Jan 26 '23 at 10:24

0 Answers0