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

ci: more robust handling of directories in shell.zig #1275

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Commits on Nov 7, 2023

  1. ci: more robust handling of directories in shell.zig

    We use shell.zig for various "scripting" tasks. One problem there is
    managing environment --- current directory and environmental variables.
    
    So far, the strategy was to avoid doing anything special about it and
    just use std API to mutate global process state. That's not great, for
    two reasons:
    
    - First, mutating process state is inherently fragile. For example,
      calling setenv in a multithreaded program is almost always UB
    
    - Second, mutating global state might lead to logical errors. For
      example, we had a bug recently where `foo` called `bar`, `bar` changed
      process working directory, and, upon return, `foo` ended up in an
      unexpected state. (#1272)
    
    To fix the issues, this PR phases our global API in favor of `Shell.cwd`
    field.
    
    Trivia: in most other languages, adding a second cwd would be quite
    confusing, as that would make the `std` API behave in unexpected ways.
    However in Zig the cwd is not ambient, but rather passed explicitly to
    almost all APIs:
    
        std.fs.cwd().readFle("Readme.me")
    
    So there's no confusion!
    matklad committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    7ab58d7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b7dca29 View commit details
    Browse the repository at this point in the history