mirror of
https://github.com/rclone/rclone.git
synced 2026-06-28 18:05:12 -04:00
The Cobra generated PowerShell completion script captures rclone's output through a pipeline with Invoke-Expression. PowerShell decodes that output using [Console]::OutputEncoding, which on non-UTF-8 hosts (for example PowerShell 5.1 on a Windows install with an OEM code page such as CP852) misinterprets the UTF-8 bytes rclone emits and corrupts remote and path names containing non-ASCII characters, so tab completion produces a path that does not exist. Inject "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8" into the generated script immediately before the Invoke-Expression call. This is safe on PowerShell 7+, where UTF-8 is already the default. If the expected line is not present (for example after a Cobra template change) the script is emitted unmodified so we never produce a corrupted completion script.