From 0269a3abffc1afb9419ba871c4addf08cf59a07e Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Wed, 21 Aug 2024 11:13:38 +0800 Subject: [PATCH] fix: use correct shell on startup --- pkg/cy/client.go | 2 ++ pkg/cy/cy_test.go | 33 +++++++++++++++++++++++++++++++++ pkg/mux/stream/cmd.go | 5 +++++ 3 files changed, 40 insertions(+) diff --git a/pkg/cy/client.go b/pkg/cy/client.go index 0bfce056..b432f3e9 100644 --- a/pkg/cy/client.go +++ b/pkg/cy/client.go @@ -85,6 +85,8 @@ func (c *Cy) NewClient(ctx context.Context, options ClientOptions) (*Client, err return nil, err } + client.params.SetParent(c.tree.Root().Params()) + c.Lock() c.clients = append(c.clients, client) c.Unlock() diff --git a/pkg/cy/cy_test.go b/pkg/cy/cy_test.go index ce04cd5c..53e9360f 100644 --- a/pkg/cy/cy_test.go +++ b/pkg/cy/cy_test.go @@ -6,7 +6,9 @@ import ( "github.com/cfoust/cy/pkg/cy/cmd" "github.com/cfoust/cy/pkg/geom" + T "github.com/cfoust/cy/pkg/mux/screen/tree" "github.com/cfoust/cy/pkg/mux/stream" + "github.com/cfoust/cy/pkg/replay" "github.com/stretchr/testify/require" ) @@ -85,3 +87,34 @@ func TestClients(t *testing.T) { clients[i].Cancel() } } + +func TestDefaultShell(t *testing.T) { + ctx := context.Background() + cy, err := Start(ctx, Options{ + Shell: "/bin/zsh", + }) + require.NoError(t, err) + + client, err := cy.NewClient(ctx, ClientOptions{ + Env: map[string]string{ + "TERM": "xterm-256color", + }, + Size: geom.DEFAULT_SIZE, + }) + require.NoError(t, err) + + node := client.Node() + require.NotNil(t, node) + + pane, ok := node.(*T.Pane) + require.True(t, ok) + + r, ok := pane.Screen().(*replay.Replayable) + require.True(t, ok) + + cmd, ok := r.Cmd().(*stream.Cmd) + require.True(t, ok) + + options := cmd.Options() + require.Equal(t, "/bin/zsh", options.Command) +} diff --git a/pkg/mux/stream/cmd.go b/pkg/mux/stream/cmd.go index 4de8b5c2..2da9361a 100644 --- a/pkg/mux/stream/cmd.go +++ b/pkg/mux/stream/cmd.go @@ -66,6 +66,11 @@ func (c *Cmd) Resize(size Size) error { }) } +// Options returns the original arguments used to start the command. +func (c *Cmd) Options() CmdOptions { + return c.options +} + func (c *Cmd) Path() (string, error) { c.RLock() proc := c.proc