aboutsummaryrefslogtreecommitdiffstats
path: root/browserenv.go
diff options
context:
space:
mode:
authorTeddy Wing2020-12-20 15:34:41 +0100
committerTeddy Wing2020-12-20 15:34:41 +0100
commitba7d8816569954193d3291e90325fc62f1cd5905 (patch)
treee2d8ea6651af10e051dccf75e0628132436c2c88 /browserenv.go
parent832026cddb55d341a025427b3d5edf770a2d71ec (diff)
downloadbrowserenv-ba7d8816569954193d3291e90325fc62f1cd5905.tar.bz2
Move browser command formatting to a new `fmtBrowserCommand()`
Not to be confused with the previous `fmtBrowserCommand()` function, this one handles all formatting including `%s`, shell escaping, etc.
Diffstat (limited to 'browserenv.go')
-rw-r--r--browserenv.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/browserenv.go b/browserenv.go
index ae1024f..e83c3d1 100644
--- a/browserenv.go
+++ b/browserenv.go
@@ -77,6 +77,14 @@ func browserCommand(command, url string) *exec.Cmd {
shell := shellArgs[0]
args := shellArgs[1:]
+ command = fmtBrowserCommand(command, url)
+
+ args = append(args, command)
+
+ return exec.Command(shell, args...)
+}
+
+func fmtBrowserCommand(command, url string) string {
url = escapeURL(url)
if browserCommandIncludesURL(command) {
@@ -85,9 +93,7 @@ func browserCommand(command, url string) *exec.Cmd {
command = shellEscapeCommand(command, url)
}
- args = append(args, command)
-
- return exec.Command(shell, args...)
+ return command
}
func browserCommandIncludesURL(command string) bool {