Skip to content

Add CHOICE and fix several build/runtime issues#9

Merged
TSnake41 merged 10 commits intodarkbatcher:devfrom
ostrich:pr/choice-build-runtime-tests
Apr 16, 2026
Merged

Add CHOICE and fix several build/runtime issues#9
TSnake41 merged 10 commits intodarkbatcher:devfrom
ostrich:pr/choice-build-runtime-tests

Conversation

@ostrich
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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.

Comment thread pbat/command/pBat_Choice.c Outdated
continue;
}

if (!stricmp(param->str, "/CS")) {
Copy link
Copy Markdown
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.

Comment thread pbat/lang/pBat_ShowHelp.h
#define PBAT_HELP_REM 13
#define PBAT_HELP_DIR 14
#define PBAT_HELP_CLS 16
#define PBAT_HELP_CHOICE 15
Copy link
Copy Markdown
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)

Comment thread pbat/command/pBat_Choice.c Outdated
return pBat_ChoiceFind(choices, def, case_sensitive);
}

static int pBat_ChoiceReadWithTimeout(double timeout_seconds)
Copy link
Copy Markdown
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
Copy Markdown
Contributor 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.

@ostrich ostrich requested a review from TSnake41 March 27, 2026 16:27
Copy link
Copy Markdown
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.

@TSnake41
Copy link
Copy Markdown
Collaborator

Well, it build with Linux, it's just that there is a bunch of missing cast around libcu8 (unrelated to this PR) for Windows.

@TSnake41 TSnake41 merged commit 78b0273 into darkbatcher:dev Apr 16, 2026
1 check failed
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