~eliasnaur/gio

ui/app: Fix init() appending '' to os.Args v1 APPLIED

Thanks! I tweaked the patch title to start with a lowercase 'f' after
the colon to match
the Go patch standard.

To git.sr.ht:~eliasnaur/gio
   7c197cc..56926a0  master -> master
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio/%3C20190814001619.9621-1-larry%40theclapp.org%3E/mbox | git am -3
Learn more about email & git

[PATCH] ui/app: Fix init() appending '' to os.Args Export this patch

init() says

  args := strings.Split(extraArgs, "|")
  os.Args = append(os.Args, args...)

strings.Split says

  If s does not contain sep and sep is not empty, Split returns a slice
  of length 1 whose only element is s.

which means init() adds a blank arg to the end of os.Args when extraArgs
is empty.  This fixes that.

Signed-off-by: Larry Clapp <larry@theclapp.org>
---
 ui/app/app.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ui/app/app.go b/ui/app/app.go
index 1613be6..26331a8 100644
--- a/ui/app/app.go
+++ b/ui/app/app.go
@@ -118,8 +118,10 @@ func (l Stage) String() string {
 }
 
 func init() {
-	args := strings.Split(extraArgs, "|")
-	os.Args = append(os.Args, args...)
+	if extraArgs != "" {
+		args := strings.Split(extraArgs, "|")
+		os.Args = append(os.Args, args...)
+	}
 }
 
 // DataDir returns a path to use for application-specific
-- 
2.22.0
Thanks! I tweaked the patch title to start with a lowercase 'f' after
the colon to match
the Go patch standard.

To git.sr.ht:~eliasnaur/gio
   7c197cc..56926a0  master -> master
View this thread in the archives