[bug] args in 'Command' is escaped.
Opened this issue · 0 comments
semanticist21 commented
Describe the bug
I'm trying to open using 'explorer.exe' command, but the path input is escaped each time, resulting in explorer process ignoring args.
Reproduction
export const getCurrentResourceDir = async () => {
const resourceDir = await path.resourceDir();
return await path.resolve(resourceDir, 'data');
};
export const openSavedFolderAsync = async () => {
const curPath = (await getCurrentResourceDir()).replaceAll('\\\\?\\', '');
const isWindows = navigator.userAgent.includes('Windows');
const isMac = navigator.userAgent.includes('Mac');
// C:\my-project\src-tauri\target\debug\data
console.log(curPath);
// args : Array(1)
// 0 : "C:\\my-project\\src-tauri\\target\\debug\\data"
// length : 1
console.log(new Command('explorer', curPath));
if (isWindows) {
// FIXME curPath is escaped
new Command('explorer', curPath).spawn();
} else if (isMac) {
new Command('open', curPath).spawn();
}
};
Expected behavior
Command executes then new folder is opened with designated path.
"explorer 'path'".
if 'path' is not fit with windows directory format, it just opens user's document folder, which I'm experiencing now.
Full tauri info
output
[✔] Environment
- OS: Windows 10.0.22631 X64
✔ WebView2: 129.0.2792.89
✔ MSVC:
- Visual Studio Build Tools 2019
- Visual Studio Community 2022
✔ rustc: 1.76.0 (07dca489a 2024-02-04)
✔ cargo: 1.76.0 (c84b36747 2024-01-18)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.4.0
- pnpm: 9.9.0
- yarn: 1.22.19
- npm: 9.7.2
- bun: 1.1.22
[-] Packages
- tauri [RUST]: 1.8.0
- tauri-build [RUST]: 1.5.5
- wry [RUST]: 0.24.11
- tao [RUST]: 0.16.10
- @tauri-apps/api [NPM]: 1.6.0 (outdated, latest: 2.0.3)
- @tauri-apps/cli [NPM]: 1.6.2 (outdated, latest: 2.0.3)
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../dist
- devPath: http://localhost:1420/
- framework: React
- bundler: Vite
Stack trace
None
Additional context
No response