resticprofile icon indicating copy to clipboard operation
resticprofile copied to clipboard

Problem with path spaces on windows using pwsh

Open tekert opened this issue 2 years ago • 4 comments

So, im trying to backup chrome - resticprofile version 0.22.0 commit ddf9debf89960db2c6139523ef6140a6538c5d27 using:

global:
  shell: pwsh
...
source:
  - "E:\\Data\\Tekert\\AppData\\Local\\Chrome\\User\ Data"
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - "E:\\Data\\Tekert\\AppData\\Local\\Chrome\\User Data"
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - 'E:\Data\Tekert\AppData\Local\Chrome\User Data'
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - E:\Data\Tekert\AppData\Local\Chrome\User Data
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping

tekert avatar Jul 05 '23 05:07 tekert

Additionaly same problems with:

restic-binary: "C:\\Program Files\\WinGet\\Links\\restic.exe"

C:\Program: The term 'C:\Program' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

tekert avatar Jul 05 '23 05:07 tekert

The issue with restic-binary is known and fixed in #224 (next release). Interesting that additional command options seem to be interpreted as shell markup as well. We already pass individual parameters (like paths) as escaped tokens, but it seems they are interpreted as powershell markup.

Before #224 is enhanced (and available), you can workaround the issue by escaping paths manually using the pwsh escape char [`]. E.g.:

source:
  - E:\Data\Tekert\AppData\Local\Chrome\User` Data

jkellerer avatar Jul 05 '23 08:07 jkellerer

Oh i see, [`] is working for now. except restic-binary path

tekert avatar Jul 05 '23 16:07 tekert

There is another problem with cmd shell this time, maybe its related,

a powershell script named myscript.ps1 with

param (
    [string] $param1,
    [string] $param2 = "a default path"
)
Write-Output "param1=$param1"
Write-Output "param2=$param2"

Called from a yaml profile with this:

global:
  shell: cmd
...
      run-before:
        - >
          powershell -ExecutionPolicy Bypass -File myscript.ps1
          -param1 <a dir with spaces>
          -param2 "<a dir with spaces>"
...

Result:

param1=<a
param2="<a

tekert avatar Jul 05 '23 17:07 tekert