Comments (15)
would
script.Env("variable", "value").Exec("command")
be a suitable solution
from script.
I'm not seeing where this adds much value over, for example:
script.Exec("sh -c 'export MSG=hello; echo $MSG'").Stdout()
from script.
on windows that syntax is not possible
from script.
That's a fair point, but what about os.Setenv
, for example?
from script.
It works but I think it would cleaner to have it inline and builtin to the module.
from script.
Useful abstractions, as John Ousterhout says, should be deep: they should conceal lots of functionality behind a simple API. Is there any way we could do more than simply call os.Setenv
? Some example programs that need to set their environment would be useful. What about reading an envfile, for example?
from script.
I think it might be nice to not use os.Setenv()
and instead only set them for a Pipeline - maybe something like a wrapper around script.Exec("sh -c 'export KEY=value; true'")
, but for potentially multiple key/value pairs? In this way, we scope environment variables to just the pipeline rather than the entire golang process that is invoking/utilizing the pipeline.
Note that the wrapper would probably need to properly escape the environment variables, so it wouldn't be as simple as a fmt.Sprintf()
call. Maybe thats enough deepness for it to be implemented?
from script.
That sounds good, @josegonzalez—can you write a short piece of example code to show what you mean?
from script.
Maybe something like the following:
environ := map[string]string{
"HASURA_GRAPHQL_JWT_SECRET": "{\"type\": \"HS256\", \"key\": \"256BITKEYHERE$\"}"
}
contents, err := script.Env(env).Exec("env")
from script.
Okay, but this looks pretty similar to:
os.Setenv("HASURA_GRAPHQL_JWT_SECRET", `{"type": "HS256", "key": "256BITKEYHERE$"}`)
contents, err := script.Exec("env")
Can you describe what problem you think an Env
method on the pipe would be solving here?
from script.
os.Setenv would be global to the entire script this would allow it be local to the pipe
from script.
Okay, but why is that important? Can you think of a situation where you'd want to set some environment variable for a command run by a pipe, but not for the program as a whole?
from script.
I'm not sure of the usecases but it just allows the same flexibility that the bash syntax allows but for all OSs
from script.
Well, if there are no use cases for something, that's just another way of saying we don't need it, isn't it? There are lots of feature ideas that aren't bad in themselves—they're great features! It's just that we don't need them, so we don't add them.
from script.
Closing pending real use cases.
from script.
Related Issues (20)
- Bytes and String methods inconsistent on non-zero exist status from Exec HOT 1
- gitignore entry for Intellij IDEA HOT 4
- Feature Request: Add FilterFunc HOT 2
- Basename introduces a line feed HOT 1
- How can I check the progress of a script.Exec() command? HOT 2
- Interaction with bubbletea HOT 10
- Propose adding a delimeter to Column()
- Add Base64 encode and decode methods HOT 3
- Suggestion: `./go-script -c 'script.Stdin()...'` tool for running these HOT 5
- Should `ExecForEach` sanitize or escape arguments differently? HOT 9
- Parameterize a script.Pipe with a user data struct ? HOT 5
- Execv function HOT 1
- how to get the stdout of the Exec result? HOT 3
- Race condition in Pipe.Exec HOT 1
- Methods for mkdir and touch HOT 2
- Conditinally execute statements. HOT 2
- How to create folder, delete folder and list folder contents ? HOT 4
- Feature Suggestion: Fields HOT 4
- Makefile replacement HOT 2
- Expand prompt logic for PR #199
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 script.