9sh

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3bbf3f7f0a91c7b7b9e3da8ed2b088eaa100c5cb
parent c92b0536fa120e05c8305b243eebe1d69599ec86
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat,  9 Dec 2023 08:35:11 +0900

add cd without args

Diffstat:
Mmain.go | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go @@ -38,10 +38,17 @@ func (c *cmd) run(s *stat) error { } switch c.args[0] { case "cd": - if len(c.args) != 2 { + var p string + if len(c.args) == 1 { + p = "." + } else if len(c.args) == 2 { + p = path.Join(s.cwd, c.args[1]) + } else { return fmt.Errorf("usage: cd <dir>") } - p := path.Join(s.cwd, c.args[1]) + if s.f != nil { + s.f.Close() + } f, err := s.fsys.Open(p) if err != nil { return err @@ -84,6 +91,7 @@ func main() { fsys: lib9p.ExportFS{fsys}, } for { + fmt.Printf("9%% ") c := <-cc if c.err == io.EOF { break