[PATCH] pager/editor: Invoke command with "sh -c"
Export this patch
Closes: https://todo.sr.ht/~emersion/hut/44
---
main.go | 2 + -
pager.go | 2 + -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/main.go b/main.go
index 7c05bee..eb18b2b 100644
--- a/main.go
+++ b/main.go
@@ -152,7 +152,7 @@ func getInputWithEditor(pattern, initialText string) (string, error) {
return "", err
}
- cmd := exec.Command(editor, file.Name())
+ cmd := exec.Command("sh", "-c", fmt.Sprintf("%s %s", editor, file.Name()))
This breaks if file.Name() contains spaces, which can happen for instance if
TMPDIR does.
We probably need to do something like:
sh -c '$EDITOR "$@"' -- <filename>
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
diff --git a/pager.go b/pager.go
index 7615f89..424d07b 100644
--- a/pager.go
@@ -24,7 +24,7 @@ func newPager() pager {
name = "less"
}
- cmd := exec.Command(name)
+ cmd := exec.Command("sh", "-c", name)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Env = append(os.Environ(), "LESS=FRX")
base-commit: 499ef88754326222b1567261ac6b39b9f2a586ed
--
2.43.0