Skip to content

Conversation

@daveads
Copy link
Contributor

@daveads daveads commented Jan 10, 2026

The exec builtin now supports the -a flag to set argv[0], matching bash behavior.

close #2558

@daveads
Copy link
Contributor Author

daveads commented Jan 10, 2026

Screenshot 2026-01-10 at 6 05 23 AM

issue

@daveads
Copy link
Contributor Author

daveads commented Jan 10, 2026

Screenshot 2026-01-10 at 5 58 58 AM

@daveads
Copy link
Contributor Author

daveads commented Jan 12, 2026

@andychu review.

Copy link
Contributor

@andychu andychu left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

(sorry for the delayed review, usually I aim for 24 hours -- but I'm still busy with family stuff)

## BUG mksh stdout-json: ""

#### exec -a sets argv[0]
exec -a FOOPROC /bin/bash -c 'echo $0'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would make this bash or better yet just sh because /bin/bash may not exist on every system

c2_argv = [arg.a]
c2_argv.extend(cmd_val.argv[i+1:])
else:
c2_argv = cmd_val.argv[i:]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be simpler like:

argv = cmd_val.argv[i:]
if arg.a is not None:
  argv[0] = arg.a

OK and actually I guess there is no way to change the location now ... but that's OK

exec -a foo python -c
             ^^^^^ # location is still python, not foo

Maybe write a comment about the location -- that controls this error

$ osh -c 'exec foo bar'
  exec foo bar
       ^~~
[ -c flag ]:1: fatal: exec: 'foo' not found

@daveads daveads requested a review from andychu January 17, 2026 14:55
@andychu andychu changed the base branch from master to soil-staging January 17, 2026 23:26
@andychu andychu merged commit 16ef54b into soil-staging Jan 17, 2026
19 checks passed
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.

exec -a not implemented

3 participants