Skip to content

Commit

Permalink
Merge pull request #350 from cogentcore/cmdcrash
Browse files Browse the repository at this point in the history
fix crash in empty command and go mod update to latest core
  • Loading branch information
kkoreilly authored Sep 2, 2024
2 parents a0741c3 + 8a18e6b commit 9ab53a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions code/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ func (cm *CmdAndArgs) PrepCmd(avp *ArgVarVals) (*exec.Cmd, string) {
switch cm.Cmd {
case "{PromptString1}": // special case -- expand args
cmdstr := cstr
args, err := shellwords.Parse(cmdstr)
if err != nil {
fmt.Println(err)
args := errors.Log1(shellwords.Parse(cmdstr))
if len(args) == 0 {
return nil, ""
}
if len(args) > 1 {
cstr = args[0]
Expand Down Expand Up @@ -482,6 +482,9 @@ func (cm *Command) RunAfterPrompts(cv *Code, buf *texteditor.Buffer) {
// line of the command output to code statusbar
func (cm *Command) RunBufWait(cv *Code, buf *texteditor.Buffer, cma *CmdAndArgs) bool {
cmd, cmdstr := cma.PrepCmd(&cv.ArgVals)
if cmd == nil {
return false
}
cv.RunningCmds.AddCmd(cm.Label(), cmdstr, cma, cmd)
out, err := cmd.CombinedOutput()
cm.AppendCmdOut(cv, buf, out)
Expand All @@ -492,6 +495,9 @@ func (cm *Command) RunBufWait(cv *Code, buf *texteditor.Buffer, cma *CmdAndArgs)
// buffer with new results line-by-line as they come in
func (cm *Command) RunBuf(cv *Code, buf *texteditor.Buffer, cma *CmdAndArgs) bool {
cmd, cmdstr := cma.PrepCmd(&cv.ArgVals)
if cmd == nil {
return false
}
cv.RunningCmds.AddCmd(cm.Label(), cmdstr, cma, cmd)
stdout, err := cmd.StdoutPipe()
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module cogentcore.org/cogent
go 1.22

require (
cogentcore.org/core v0.3.3-0.20240902172924-b432919e181b
cogentcore.org/core v0.3.3-0.20240902213628-48df10901467
github.com/aandrew-me/tgpt/v2 v2.7.2
github.com/alecthomas/chroma/v2 v2.13.0
github.com/bogdanfinn/fhttp v0.5.27
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cogentcore.org/core v0.3.3-0.20240902172924-b432919e181b h1:G7CC9jK/8FWCOYrc83VR5raE82xCkTlG3/h63txQ5Pw=
cogentcore.org/core v0.3.3-0.20240902172924-b432919e181b/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
cogentcore.org/core v0.3.3-0.20240902213628-48df10901467 h1:AL9pi5H1ttL76EpnqBCCaflNnfwRxuezZOApoSOL564=
cogentcore.org/core v0.3.3-0.20240902213628-48df10901467/go.mod h1:dg3uRsPcd8S1ZYvRD2TztCtjopRkrB5V/lbl54xsQd4=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4 h1:6lx9xzJAhdjq0LvVfbITeC3IH9Fzvo1aBahyPu2FuG8=
github.com/Bios-Marcel/wastebasket v0.0.4-0.20240213135800-f26f1ae0a7c4/go.mod h1:FChzXi1izqzdPb6BiNZmcZLGyTYiT61iGx9Rxx9GNeI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down

0 comments on commit 9ab53a8

Please sign in to comment.