Giter Site home page Giter Site logo

Comments (10)

joshnesbitt avatar joshnesbitt commented on August 21, 2024

Hmmm. To be honest I never really wanted the commands to execute within the context of the parent shell as running in a subshell would enable you to continue working as you were within the parent shell. I do however see how this behaviour could be beneficial though. Any ideas on how this could be done? I'll have a dig around and see. Thanks for reporting!

from project.

joshnesbitt avatar joshnesbitt commented on August 21, 2024

It would also be really useful to see shell state to be preserved between workflow items too, but stringing them all into one long command isn't the solution.

from project.

itstommymorgan avatar itstommymorgan commented on August 21, 2024

There's another issue, too, in that each use of %x[ ] will create it's own subshell.

e.g.:

%x[ cd %path ]
%x[ pwd ]

should demonstrate that any sequence of commands that affect shell variables (like the current working directory) won't have any effect on commands later on down the workflow. So workflows like

:default:
  - cd %path
  - rake

would also be rendered useless.

The latter could possibly be solved by taking the commands and executing them altogether, rather than individually (e.g. %x[ cd %path; rake ]). Still not sure how to solve the issue where somebody simply wants to 'jump' to the project directory, though.

from project.

itstommymorgan avatar itstommymorgan commented on August 21, 2024

Another possible option: create a shell script in a temporary directory containing all the commands that you then execute and delete.

from project.

joshnesbitt avatar joshnesbitt commented on August 21, 2024

Almost beat me to it ;) just on my phone at the moment but will definitely take a look at this when I get back, it's quite a big blocker for creating better workflows.

from project.

joshnesbitt avatar joshnesbitt commented on August 21, 2024

After looking around it seems that no matter how the problem is approached in Ruby, the effect might still be the same. Child processes cannot alter the parent processes state. One option would be to wrap the gem within a bash script so we have more control over the running process. Or maybe going against what I said above I could look for common commands (such as cd) and use the Ruby libraries to perform them instead of shelling out.

Any ideas?

from project.

itstommymorgan avatar itstommymorgan commented on August 21, 2024

If you don't want it to affect the parent shell, then the best thing to do (I think) is still to dump the commands out to a temporary shell script that gets executed.

If you want it to be able to affect the parent shell, that would have to involve creating a shell function.

from project.

joshnesbitt avatar joshnesbitt commented on August 21, 2024

In what cases would creating a temp script be more beneficial over just chaining the commands? I might opt to not affect the parent shell for now but will look into it in the future.

from project.

itstommymorgan avatar itstommymorgan commented on August 21, 2024

Well, if memory serves, most shells have some sort of a command line length limit. So any sufficiently advanced workflow wouldn't work if you tried to chain it together. I'd have to do a bit of research to determine what constitutes 'sufficiently advanced,' though. It could be that it's large enough to be of no concern.

from project.

joshnesbitt avatar joshnesbitt commented on August 21, 2024

Sure, let me know if you find anything, otherwise I'll probably go down that route now whilst looking for a more elegant fix.

from project.

Related Issues (10)

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.