Comments (4)
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.
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.
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.
Commit fb6f0b1 fixes this issue.
from cbwin.
Related Issues (20)
- wrun: can't translate a WSL VolFs path to a Win32 one HOT 7
- Default command handler HOT 10
- some win32 console programs "sometimes" do line feed instead of new line, but a workaround seems possible HOT 1
- a cmd-like behavior distinguishing between console / GUI target programs might be useful HOT 1
- backgrounded & force redirected caller => SIGTTIN
- Use double quotes to prevent word splitting may be better HOT 12
- Problem with arguments containing the character "&" HOT 1
- wcmd cmd no longer laggy, but eats characters HOT 1
- Let cbwin in session mode launch multiple wcmd instances in parallel HOT 11
- sockets for redirections are not using any security HOT 6
- wstart /mnt/c/windows does not work HOT 7
- Not work inside zsh HOT 14
- behavior of environment variable inconsistent in regards to case sensitivity HOT 1
- No terminal support HOT 6
- Vagrant output doesn't wrap correctly HOT 4
- interactive win32 console programs are broken (input and output) HOT 5
- Native Windows support for launching Windows applications HOT 1
- Some inputted characters skipped in Docker interactive terminal HOT 1
- Starting parameters for bash.exe
- Can't remove cbwin from my pc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbwin.