You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
541 B
Go
27 lines
541 B
Go
package commands
|
|
|
|
import "strings"
|
|
|
|
func AssignmentsToMap(args []string) map[string]string {
|
|
var assignments = make(map[string]string)
|
|
for _, arg := range args {
|
|
split := strings.Split(arg, "=")
|
|
if len(split) > 1 {
|
|
assignments[split[0]] = split[1]
|
|
}
|
|
}
|
|
|
|
return assignments
|
|
}
|
|
|
|
func ApplyEnvIfPresent(shell *Shell, comm *Command) {
|
|
var args []string
|
|
args = append(args, comm.Name)
|
|
args = append(args, comm.Arguments...)
|
|
|
|
assignments := AssignmentsToMap(args)
|
|
if ps1, ok := assignments["PS1"]; ok {
|
|
shell.SetPrompt(ps1)
|
|
}
|
|
}
|