Introduction
Introduction Statistics Contact Development Disclaimer Help
smdev SMDEV environment fix and small optimization - smdev - suckless mdev
git clone git://git.suckless.org/smdev
Log
Files
Refs
README
LICENSE
---
commit 7550047abc4f7db1da453ae8927866b512f95a03
parent ddacaa6b20569d4fb4be3de615434f5f59fe9b28
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 6 Apr 2014 15:59:39 +0200
smdev SMDEV environment fix and small optimization
Use setenv() with overwrite flag to set environment variable. This fixes an iss…
Optimization: check if rule->cmd is set, else don't change directory to /dev an…
Signed-off-by: Hiltjo Posthuma <[email protected]>
Diffstat:
M smdev.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
---
diff --git a/smdev.c b/smdev.c
@@ -223,14 +223,13 @@ removedev(struct event *ev)
parsepath(rule, &rpath, ev->devname);
- if (chdir("/dev") < 0)
- eprintf("chdir /dev:");
-
- snprintf(buf, sizeof(buf), "SMDEV=%s", ev->devname);
- if (putenv(buf) < 0)
- eprintf("putenv:");
-
- runrulecmd(rule);
+ if(rule->cmd) {
+ if (chdir("/dev") < 0)
+ eprintf("chdir /dev:");
+ if (setenv("SMDEV", ev->devname, 1) < 0)
+ eprintf("setenv:");
+ runrulecmd(rule);
+ }
if (chdir(ocwd) < 0)
eprintf("chdir %s:", ocwd);
@@ -313,14 +312,13 @@ createdev(struct event *ev)
}
runrule:
- if (chdir("/dev") < 0)
- eprintf("chdir /dev:");
-
- snprintf(buf, sizeof(buf), "SMDEV=%s", ev->devname);
- if (putenv(buf) < 0)
- eprintf("putenv:");
-
- runrulecmd(rule);
+ if(rule->cmd) {
+ if (chdir("/dev") < 0)
+ eprintf("chdir /dev:");
+ if (setenv("SMDEV", ev->devname, 1) < 0)
+ eprintf("setenv:");
+ runrulecmd(rule);
+ }
if (chdir(ocwd) < 0)
eprintf("chdir %s:", ocwd);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.