Comments (9)
Renamed to BeforeExec
and released as v1.4.0.
from cmd.
It's a good idea to me. I do want to setup the cmd.SysProcAttr.Credential
so that I can run commands under another user.
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uid, Gid: gid}
Refer to https://stackoverflow.com/a/21706757/14833782
from cmd.
@wenerme @Callisto13 et al. I merged PR #54 but reworked in PR #75. Here's why...
Cmd.Options
is too close to the Options
struct. And this latter is where I'm trying to move options so that Cmd
doesn't become overloaded with optional fields. So Options.SetCmd
is the better design, but it means you need to specify the callbacks like the test:
p := cmd.NewCmdOptions(
cmd.Options{
SetCmd: []func(cmd *exec.Cmd){
func(cmd *exec.Cmd) { handled = true },
},
},
"/bin/ls",
)
If that doesn't work, then I could add Cmd.SetCmd
, too, which combines with any Options.SetCmd
. Reason being: looking ahead, I'm thinking that v2 of this pkg move all things to Options
, so Cmd.SetCmd
would be a deprecated featured for the start.
from cmd.
currently using this fork #54
from cmd.
Re #54: do you just wanted to set SysProcAttr
, or do you want a more general-purpose callback like feature (like in that PR)?
from cmd.
I prefer the general-purpose callback, like use this if you know what you are doing.
from cmd.
Thanks @daniel-nichter for looking into this. For my user case, both will work fine. I would vote for the general-purpose callback although(as in #54 ) as it will give people a lot more flexibility on using this cool tool.
from cmd.
lgtm, but SetCmd feels strange, more like BeforeExec or something, like hook
from cmd.
Yeah, the same occurred to me and I wrote it as BeforeExec
at one point. Although its original intent was to set/modify the underlying os/exec.Exec
, its actual function is a generic before-exec callback/hook. Will think on it, and see if others have ideas, before the v1.4 release (where this will appear officially).
from cmd.
Related Issues (20)
- wrong description of Status for receiving a signal of interrupt HOT 2
- not support cmd HOT 1
- Is there a way to have stderr buffered into stdout HOT 3
- example cmd.NewCmdOptions not working HOT 1
- is it possible to change password? HOT 1
- Windows10 HOT 3
- Part of #11517
- Updated and install
- How can I execute a sentence command directly? HOT 1
- 🔊
- Stdout empty when using Streaming HOT 6
- unable to use with binary stdout HOT 2
- Running a script to start an external application, when the main application terminates, the one started from the script crashes as it no longer has an Stdout & Stderr HOT 1
- make terminating process group optional HOT 1
- python command in streaming mode not streaming the stdout HOT 2
- cant go get HOT 3
- Command is still executed if Stop() is called during BeforeExec hooks HOT 1
- How to restart after Stop()
- the replacement of "+build" to "go:build" needs a change of go version in go mod
- when the process is ready 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 cmd.