mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-19 00:27:06 +00:00
feat(GODT-2666): feat(GODT-2667): introduce sessionID in bridge.
This commit is contained in:
@ -77,7 +77,7 @@ func (restarter *Restarter) Restart() {
|
||||
//nolint:gosec
|
||||
cmd := execabs.Command(
|
||||
restarter.exe,
|
||||
xslices.Join(removeFlagWithValue(removeFlag(os.Args[1:], "no-window"), "parent-pid"), restarter.flags)...,
|
||||
xslices.Join(removeFlagsWithValue(removeFlag(os.Args[1:], "no-window"), "parent-pid", "session-id"), restarter.flags)...,
|
||||
)
|
||||
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
@ -157,6 +157,16 @@ func removeFlagWithValue(argList []string, flag string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
// removeFlagWithValue removes flags that require a value from a list of command line parameters.
|
||||
// The flags can be of the following form `-flag value`, `--flag value`, `-flag=value` or `--flags=value`.
|
||||
func removeFlagsWithValue(argList []string, flags ...string) []string {
|
||||
for _, flag := range flags {
|
||||
argList = removeFlagWithValue(argList, flag)
|
||||
}
|
||||
|
||||
return argList
|
||||
}
|
||||
|
||||
func removeFlag(argList []string, flag string) []string {
|
||||
return xslices.Filter(argList, func(arg string) bool { return (arg != "-"+flag) && (arg != "--"+flag) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user