Skip to content

Add CHOICE and fix several build/runtime issues#9

Open
ostrich wants to merge 8 commits intodarkbatcher:devfrom
ostrich:pr/choice-build-runtime-tests
Open

Add CHOICE and fix several build/runtime issues#9
ostrich wants to merge 8 commits intodarkbatcher:devfrom
ostrich:pr/choice-build-runtime-tests

Conversation

@ostrich
Copy link

@ostrich ostrich commented Mar 23, 2026

Summary

This branch adds a CHOICE builtin and includes a set of build, runtime, and test fixes that came up while implementing and validating it on Linux.

Changes

  • add CHOICE support with /C, /N, /CS, /D, /T, /M, and DOS-style /T:X,1
  • fix Unix config/build issues
  • fix runtime bugs in pipes, redirection, COPY, CALL, and IF ERRORLEVEL
  • fix several portability/correctness issues found during build/test
  • expand the regression test suite
  • small output/prompt fixes (DIR, prompt flushing, path-independent TYPE test output)

Validation

Tested on Linux with:

make config
make all bin -j4
make -C tests test PBAT=../pbat/pbat -j1

Copy link
Collaborator

@TSnake41 TSnake41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, just found a few nits/small issues.

continue;
}

if (!stricmp(param->str, "/CS")) {
Copy link
Collaborator

@TSnake41 TSnake41 Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/CS starts with /C and gets catched by the /C check instead.

#define PBAT_HELP_REM 13
#define PBAT_HELP_DIR 14
#define PBAT_HELP_CLS 16
#define PBAT_HELP_CHOICE 15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea to use the gap (which is probably there due to a mistake).

Some nits :

  • it's off by a line (breaking the ordering)
  • you don't actually need to increase PBAT_HELP_ARRAY_SIZE (latest help index was 40 and is still 40)

return pBat_ChoiceFind(choices, def, case_sensitive);
}

static int pBat_ChoiceReadWithTimeout(double timeout_seconds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm don't think it's very useful to use floats for timeout given that you are only manipulating (and allowing) integers in the end.

@ostrich
Copy link
Author

ostrich commented Mar 24, 2026

Thanks, good catches. I fixed the /CS parsing order, cleaned up the help ID/array size, and simplified the timeout handling to use integer milliseconds instead of float bookkeeping. I’ve pushed the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants