diff options
author | Teddy Wing | 2020-12-20 15:34:41 +0100 |
---|---|---|
committer | Teddy Wing | 2020-12-20 15:34:41 +0100 |
commit | ba7d8816569954193d3291e90325fc62f1cd5905 (patch) | |
tree | e2d8ea6651af10e051dccf75e0628132436c2c88 | |
parent | 832026cddb55d341a025427b3d5edf770a2d71ec (diff) | |
download | browserenv-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.
-rw-r--r-- | browserenv.go | 12 |
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 { |