From 07e1da21330b00b0b621e7f9959c7c3717995e93 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Fri, 1 Nov 2024 00:55:30 +0100 Subject: [PATCH 1/3] #440: Add Shell: sh --- src/shells/ShellFunctions.ts | 2 ++ src/shells/Shell_Sh.ts | 60 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/shells/Shell_Sh.ts diff --git a/src/shells/ShellFunctions.ts b/src/shells/ShellFunctions.ts index 2b936b2..3be8ce3 100644 --- a/src/shells/ShellFunctions.ts +++ b/src/shells/ShellFunctions.ts @@ -23,6 +23,7 @@ import {Shell} from "./Shell"; import {Shell_Bash} from "./Shell_Bash"; import {Shell_Dash} from "./Shell_Dash"; import {Shell_Zsh} from "./Shell_Zsh"; +import {Shell_Sh} from "./Shell_Sh"; import {Shell_PowerShellCore} from "./Shell_PowerShellCore"; import {Shell_PowerShell5} from "./Shell_PowerShell5"; import {Shell_CMD} from "./Shell_CMD"; @@ -37,6 +38,7 @@ export function registerBuiltinShells(plugin: SC_Plugin) { registerShell(new Shell_Bash(plugin)); registerShell(new Shell_Dash(plugin)); registerShell(new Shell_Zsh(plugin)); + registerShell(new Shell_Sh(plugin)); registerShell(new Shell_PowerShellCore(plugin)); registerShell(new Shell_PowerShell5(plugin)); registerShell(new Shell_CMD(plugin)); diff --git a/src/shells/Shell_Sh.ts b/src/shells/Shell_Sh.ts new file mode 100644 index 0000000..eb2cf49 --- /dev/null +++ b/src/shells/Shell_Sh.ts @@ -0,0 +1,60 @@ +/* + * 'Shell commands' plugin for Obsidian. + * Copyright (C) 2021 - 2024 Jarkko Linnanvirta + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3.0 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact the author (Jarkko Linnanvirta): https://github.com/Taitava/ + */ + +import {PlatformId} from "../settings/SC_MainSettings"; +import {normalizePath2} from "../Common"; +import {ShEscaper} from "../variables/escapers/ShEscaper"; +import {BuiltinShell} from "./BuiltinShell"; + +export class Shell_Sh extends BuiltinShell { + protected ownedShellBinaries = [ + "sh" + ]; + + protected getEscaper(rawValue: string): ShEscaper { + return new ShEscaper(rawValue); + } + + public getName(): string { + return "Sh"; + } + + public getBinaryPath(): string { + return "/bin/sh"; + } + + public getSupportedHostPlatforms(): PlatformId[] { + return [ + "darwin", // macOS + "linux", + ]; + } + + public getPathSeparator(): ":" { + return ":"; + } + + public translateAbsolutePath(originalPath: string): string { + return normalizePath2(originalPath, false); + } + + public translateRelativePath(originalPath: string): string { + return normalizePath2(originalPath, false); + } +} \ No newline at end of file From 6abe82d66b1a4c6bdb2b390c2813c763321f3e1a Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Fri, 1 Nov 2024 00:56:04 +0100 Subject: [PATCH 2/3] #440: removed 'sh' entry in Shell_Bash since it's now covered by Shell_Sh --- src/shells/Shell_Bash.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/shells/Shell_Bash.ts b/src/shells/Shell_Bash.ts index 82ee456..3589dea 100644 --- a/src/shells/Shell_Bash.ts +++ b/src/shells/Shell_Bash.ts @@ -25,7 +25,6 @@ import {BuiltinShell} from "./BuiltinShell"; export class Shell_Bash extends BuiltinShell { protected ownedShellBinaries = [ "bash", - "sh", // Sh might be something else than Bash, too, but make at least some Shell_* class recognise it. // TODO: Need to test that this works. ]; protected getEscaper(rawValue: string): ShEscaper { From 479162a74ac6cc8ebb285d5d46e4c3b8ca75ca3d Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Sat, 7 Dec 2024 18:38:17 +0100 Subject: [PATCH 3/3] Added husjon as author --- AUTHORS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index ca3278d..d452362 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -54,6 +54,14 @@ Contact: Contact: - https://github.com/jvsteiner +## Jon Erling Hustadnes +- Contributor: + - Adding shell (`/bin/sh`) +- Ideas and feedback + +Contact: +- http://github.com/husjon +