aboutsummaryrefslogtreecommitdiffstats
path: root/password_cmd.go
diff options
context:
space:
mode:
authorTeddy Wing2017-06-04 02:07:50 +0200
committerTeddy Wing2017-06-04 02:07:50 +0200
commit02e4fb5d0d95b8c5c5442ee0a97b960f1296c236 (patch)
tree4cf323694692322036b80d2d921ff966096c6c36 /password_cmd.go
parent055301ca09d57b759b290d897bbb7560460251ca (diff)
parent9b6a6543e351308939bd420243507368b0669e63 (diff)
downloadtimetasker-02e4fb5d0d95b8c5c5442ee0a97b960f1296c236.tar.bz2
Merge branch 'timetasker-daily'
Diffstat (limited to 'password_cmd.go')
-rw-r--r--password_cmd.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/password_cmd.go b/password_cmd.go
new file mode 100644
index 0000000..821c8f6
--- /dev/null
+++ b/password_cmd.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "os"
+ "os/exec"
+)
+
+// Execute the given string as a shell command and return the resulting output
+func passwordCmd(password_cmd string) (password string, err error) {
+ shell := os.Getenv("SHELL")
+
+ // `Command` requires us to pass shell arguments as parameters to the
+ // function, but we don't know what the arguments are because
+ // `password_cmd` is an arbitrary command. To get around this, we pass the
+ // password command to the current shell to execute.
+ output, err := exec.Command(shell, "-c", password_cmd).Output()
+ if err != nil {
+ return "", err
+ }
+
+ return string(output), nil
+}