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

feat: implement source #102

Merged
merged 4 commits into from
Sep 11, 2024
Merged

feat: implement source #102

merged 4 commits into from
Sep 11, 2024

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Sep 10, 2024

Fixes #94.

I am not sure about the exact semantics. Currently, everything that is modified in the sourced' script is also going to be modified in the parent script.

@wolfv wolfv changed the title Source a script feat: implement source Sep 10, 2024
@certik
Copy link
Collaborator

certik commented Sep 10, 2024

Probably time to fix #82. :) And define the exact semantics with tests, and we can always check that Bash behaves the same way.

I think the current semantics is correct, I think sourcing a script is equivalent to copy & pasting the script into the parent script and execute there.

@certik
Copy link
Collaborator

certik commented Sep 10, 2024

I tested this on Windows and it works! I can now load ~/.shellrc to load paths for pixi and my ~/bin directory.

I think this unblocks me, I can now create scripts for various conda environments, and this might be all that was needed to start using shell for my daily work.

@certik
Copy link
Collaborator

certik commented Sep 11, 2024

Found a bug: #113.

@wolfv wolfv merged commit b2c752b into main Sep 11, 2024
4 checks passed
@wolfv wolfv deleted the source branch September 11, 2024 01:10
let stdout = ShellPipeWriter::stdout();
let stdin = ShellPipeReader::stdin();

if let Err(e) = list {
Copy link
Collaborator

@prsabahrami prsabahrami Sep 11, 2024

Choose a reason for hiding this comment

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

@wolfv Is there any reason we are bailing on syntax errors? This causes shell to exit on syntax errors in interactive mode.
Previously the error was being written to stderr.

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 we might want to catch the error somewhere upstream!

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.

Implement "source a.sh"
3 participants