ToShell applies the env diff as a set of commands that are understood by the target `shell`. The outputted string is then meant to be evaluated in the target shell.
(shell Shell)
| 85 | // the target `shell`. The outputted string is then meant to be evaluated in |
| 86 | // the target shell. |
| 87 | func (diff *EnvDiff) ToShell(shell Shell) (string, error) { |
| 88 | e := make(ShellExport) |
| 89 | |
| 90 | for key := range diff.Prev { |
| 91 | _, ok := diff.Next[key] |
| 92 | if !ok { |
| 93 | e.Remove(key) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | for key, value := range diff.Next { |
| 98 | e.Add(key, value) |
| 99 | } |
| 100 | |
| 101 | return shell.Export(e) |
| 102 | } |
| 103 | |
| 104 | // Patch applies the diff to the given env and returns a new env with the |
| 105 | // changes applied. |