Git Product home page Git Product logo

Comments (5)

Arcterus avatar Arcterus commented on June 5, 2024

If no one has a preference/feels like it is useful, I am leaning towards dropping it as I'm not sure the added complexity is worth it.

from mesabox.

Arcterus avatar Arcterus commented on June 5, 2024

Hit the wrong button.

from mesabox.

Arcterus avatar Arcterus commented on June 5, 2024

One option might be to keep the file descriptor in UtilData rather than the name of the current directory and then use the *at functions (like openat) to access files (although we might need to keep the directory path as well to pass to crates we use). When changing directories we'd just have to replace the file descriptor (and path if we need to keep that as well).

This solution would help avoid the allocation issue while still maintaining the current functionality. The downsides are that writing utilities remains less ergonomic than normal binaries and that we'd need to either use nix/libc functions directory or use less vetted libraries (e.g. openat).

from mesabox.

mssun avatar mssun commented on June 5, 2024

No preference for me. I think we can drop it to keep the the code clean and simple.

from mesabox.

Arcterus avatar Arcterus commented on June 5, 2024

Only thing about this that needs consideration really is what to do with cd in sh. Currently, we try to avoid forking as much as possible, so we don't actually spawn real subshells if we can avoid doing so. The problem with that is that if the user changes the directory in one of the fake "subshells," the directory will changed outside of the "subshell."

My line of thought right now is that we should avoid forking until we see cd, in which case we fork and execute the rest of the commands for the current subshell in a real subshell. Doing so requires keeping track of whether we are in a fake "subshell" and ensuring we only fork when we haven't already done so for the current "subshell."

Another solution might be to change the directory and then change it back once the "subshell" exits, but this could cause issues if env::set_current_dir() fails after the current working directory has already been changed. This solution might also cause problems if we ever add multi-threading or other related features.

(Note that currently cd just doesn't worry about any of this and changes the directory no matter if it's in a subshell or not and it ignores actual_path(), so we will need to change it regardless of our solution).

from mesabox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.