Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: more builtin commands #9908

Merged
merged 16 commits into from
Apr 5, 2024
Merged

shell: more builtin commands #9908

merged 16 commits into from
Apr 5, 2024

Conversation

nektro
Copy link
Member

@nektro nektro commented Apr 4, 2024

#9716 progress

added yes, seq, dirname, basename.

Copy link
Contributor

github-actions bot commented Apr 4, 2024

Copy link
Contributor

github-actions bot commented Apr 4, 2024

Copy link
Contributor

github-actions bot commented Apr 4, 2024

@nektro 1 files with test failures on bun-darwin-aarch64:

View test output

#12b5044623f1758b568be1c4a0bda1464662744b

Copy link
Contributor

github-actions bot commented Apr 4, 2024

Copy link
Contributor

github-actions bot commented Apr 4, 2024

@@ -5174,27 +5157,25 @@ pub const Interpreter = struct {
}

/// **WARNING** You should make sure that stdout/stderr does not need IO (e.g. `.needsIO(.stderr)` is false before caling `.writeNoIO(.stderr, buf)`)
pub fn writeNoIO(this: *Builtin, comptime io_kind: @Type(.EnumLiteral), buf: []const u8) usize {
pub fn writeNoIO(this: *Builtin, comptime io_kind: @Type(.EnumLiteral), buf: []const u8) Maybe(usize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, because the previous value was a usize, almost every call to (about 34 of them) writeNoIO() discarded the value (e.g. _ = writeNoIO())

I think we should revert this change and do it in another PR as it will require a lot of changes to handle the error everywhere

Copy link
Member Author

Choose a reason for hiding this comment

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

I think its okay if most ignore it, but in yes it was imperative so that it knows when to stop

src/shell/interpreter.zig Outdated Show resolved Hide resolved
src/shell/interpreter.zig Outdated Show resolved Hide resolved
Comment on lines +9582 to +9583
const str = std.fmt.allocPrint(arena.allocator(), "{d}", .{current}) catch bun.outOfMemory();
defer _ = arena.reset(.retain_capacity);
Copy link
Contributor

Choose a reason for hiding this comment

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

What about printing to this.buf.writer() instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

buf is only used if this.bltn.stdout.needsIO()

this.buf.appendSlice(bun.default_allocator, msg) catch bun.outOfMemory();
return Maybe(void).success;
}
const res = this.bltn.writeNoIO(.stdout, msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suffers from same problem as Yes, example:

await Promise.all([$`seq 9999`, $`cat src/js_parser.zig`]);

Copy link
Member Author

@nektro nektro Apr 4, 2024

Choose a reason for hiding this comment

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

this may be a latent bug from elsewhere since bun-debug exec 'seq 9999' exits near instantly as do bun exec 'cat file'

src/shell/interpreter.zig Outdated Show resolved Hide resolved
@ghiscoding
Copy link

it might also be a good idea to update the website (built-in commands) I see only 6 commands as implemented on the website but in reality it's closer to 15 with this PR

@Jarred-Sumner Jarred-Sumner merged commit fd3cd05 into main Apr 5, 2024
28 of 33 checks passed
@Jarred-Sumner Jarred-Sumner deleted the nektro-patch-6755 branch April 5, 2024 23:29
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.

5 participants