Feature: support Int return from main in compiled programs for Unix exit codes #355

Closed
opened 2026-02-26 21:55:35 +00:00 by navicore · 2 comments
navicore commented 2026-02-26 21:55:35 +00:00 (Migrated from github.com)

Background

Script mode already supports main ( -- Int ) so that exit codes work correctly with bash and other shell scripts. Compiled programs currently only support main ( -- ).

Request

Allow compiled programs to also use main ( -- Int ) to return an exit code, mirroring script mode behaviour:

: main ( -- Int )
  do-work
  0    # success
;

This would encourage good Unix etiquette — programs that exit with meaningful codes can be composed with &&, ||, $?, set -e, etc.

Proposed behaviour

  • main ( -- ) continues to work (exits with code 0)
  • main ( -- Int ) uses the return value as the process exit code
  • Both forms valid in both script and compiled modes

Notes

Script mode already implements this. The compiled path just needs the same treatment at the entry point.

## Background Script mode already supports `main ( -- Int )` so that exit codes work correctly with bash and other shell scripts. Compiled programs currently only support `main ( -- )`. ## Request Allow compiled programs to also use `main ( -- Int )` to return an exit code, mirroring script mode behaviour: ```seq : main ( -- Int ) do-work 0 # success ; ``` This would encourage good Unix etiquette — programs that exit with meaningful codes can be composed with `&&`, `||`, `$?`, `set -e`, etc. ## Proposed behaviour - `main ( -- )` continues to work (exits with code 0) - `main ( -- Int )` uses the return value as the process exit code - Both forms valid in both script and compiled modes ## Notes Script mode already implements this. The compiled path just needs the same treatment at the entry point.
navicore commented 2026-04-11 12:55:11 +00:00 (Migrated from github.com)

while arguably a feature request, I'm viewing this as a very bad bug to be fixed via https://github.com/navicore/patch-seq/blob/main/docs/design/MAIN_EXIT_CODE.md

while arguably a feature request, I'm viewing this as a very bad bug to be fixed via https://github.com/navicore/patch-seq/blob/main/docs/design/MAIN_EXIT_CODE.md
navicore commented 2026-04-11 15:23:36 +00:00 (Migrated from github.com)
https://github.com/navicore/patch-seq/pull/397
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
navicore/patch-seq#355
No description provided.