blob: 27fc330eb84e578bfae836a68f879eda975c0fb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright (c) 2020 Teddy Wing
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// +build !windows
package browserenv
import (
"fmt"
"os"
)
// shell returns the current shell specified by the SHELL environment variable
// along with a "-c" argument. If SHELL is undefined, `/bin/sh` is used.
func shell() (args []string) {
shell := os.Getenv("SHELL")
if shell == "" {
shell = "/bin/sh"
}
return []string{shell, "-c"}
}
// shellEscapeCommand formats a browser command with url, escaping url by
// wrapping it in single quotes.
func shellEscapeCommand(browser, url string) string {
return fmt.Sprintf("%s '%s'", browser, url)
}
|