From 3b234c766eea266615571a51ff7577a2dee92e7e Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Thu, 26 Feb 2026 20:20:57 +0530 Subject: [PATCH] refactor: use sh and printf to write --- src-tauri/capabilities/shell.json | 9 ++------- src/helpers/use-linux-registerer.ts | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src-tauri/capabilities/shell.json b/src-tauri/capabilities/shell.json index 43ea75f..668a13f 100644 --- a/src-tauri/capabilities/shell.json +++ b/src-tauri/capabilities/shell.json @@ -66,13 +66,8 @@ "args": true }, { - "name": "cp", - "cmd": "cp", - "args": true - }, - { - "name": "echo", - "cmd": "echo", + "name": "sh", + "cmd": "sh", "args": true } ] diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index 07eb611..32c3803 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -35,7 +35,7 @@ export function useLinuxRegisterer() { description: "NeoDLP MsgHost", path: `${homeDirPath}/.local/bin/neodlp-msghost`, type: "stdio", - allowed_extension: ["neodlp@neosubhamoy.com"] + allowed_extensions: ["neodlp@neosubhamoy.com"] }; const filesToCopy: FileMap[] = [ @@ -56,8 +56,9 @@ export function useLinuxRegisterer() { for (const file of filesToCopyFlatpak) { const sourcePath = await join(resourceDirPath, file.source); const destinationPath = await join(homeDirPath, file.destination); - const copyCommand = Command.create('cp', [sourcePath, destinationPath]); - const writeCommand = Command.create('echo', [file.content || '', '>', destinationPath]); + const escapedContent = file.content?.replace(/'/g, `'\\''`) || ''; + const copyCommand = Command.create('sh', ['-c', 'cp', sourcePath, destinationPath]); + const writeCommand = Command.create('sh', ['-c', `printf '%s' '${escapedContent}' > "${destinationPath}"`]); if (file.content) { const writeOutput = await writeCommand.execute();