Giter VIP home page Giter VIP logo

Comments (4)

xilun avatar xilun commented on July 20, 2024

Actually the best way with bash -c seems to be to prepend e.g. "export OUTBASH_PORT=4242 ; " to the option of -c. This covers e.g. outbash -c "wcmd echo foobar; wcmd echo 2000", translated to bash -c "export OUTBASH_PORT=4242 ; ""wcmd echo foobar; wcmd echo 2000", whereas with env it would only apply to the first wcmd.

from cbwin.

xilun avatar xilun commented on July 20, 2024

An alternative way would be to wrap the whole bash command with another one like that:

outbash -c "echo kikoo \$OUTBASH_PORT"
=>
bash.exe -c "env OUTBASH_PORT=4242 bash -c \"echo kikoo \\\$OUTBASH_PORT\""

This is slightly better because multiple commands in a -c force bash to continue to run, waiting for each command, including the last one, while a single one seems optimized as an exec. The proper optimization should be to tail exec the last command (in which case there would be no reason to prefer this bash -c within bash -c hack), but GNU bash does not seem to do that.

Anyway, for now I think I'll go with "export OUTBASH_PORT=4242 ; ", because in the inception case proper escaping would be required.

Edit: the inception solution also uses 2 more exec, so it's not clear it is that much better...
Edit2: but the inception solution works for arbitrary command lines, not only those with a '-c' option.

from cbwin.

xilun avatar xilun commented on July 20, 2024

So I think I'll go for the generalized inception solution, because it works better regardless of the options you pass to bash (for example with the current implementation login shells also do not get OUTBASH_PORT...)

Edit_999999: hm calling env is not really necessary => one less extra exec.

from cbwin.

xilun avatar xilun commented on July 20, 2024

Commit fb6f0b1 fixes this issue.

from cbwin.

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.