2018-08-18 21:52:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
f, err := os.Open("env.sh")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("could not open env.sh: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s := bufio.NewScanner(f)
|
2018-08-18 22:01:21 +00:00
|
|
|
fmt.Println(" environment:")
|
2018-08-18 21:52:39 +00:00
|
|
|
|
|
|
|
for s.Scan() {
|
|
|
|
if strings.HasPrefix(s.Text(), "export ") {
|
|
|
|
//Store the variable name in v[0] and the value in v[1]
|
|
|
|
//then strip the quotes from the value.
|
|
|
|
v := strings.Split(s.Text()[7:], "=")
|
2018-08-18 23:26:30 +00:00
|
|
|
v[1] = strings.Join(v[1:], "=")
|
2018-08-18 21:52:39 +00:00
|
|
|
v[1] = strings.TrimSuffix(v[1], "\"")
|
|
|
|
v[1] = strings.TrimPrefix(v[1], "\"")
|
2018-08-18 22:01:21 +00:00
|
|
|
fmt.Printf(" - %s=%s\n", v[0], v[1])
|
2018-08-18 21:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := s.Err(); err != nil {
|
|
|
|
log.Fatalf("reading env.sh: %s", err)
|
|
|
|
}
|
|
|
|
}
|