summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-01-09 15:25:08 +0100
committerErich Eckner <git@eckner.net>2018-01-09 15:29:15 +0100
commit6f5ae98c0ba75b220eb6ef4b0e8bbc8cc27af9f8 (patch)
treebe222d704e4935bff315d0cae29cb84c09981980
parentce843fd0be7e5f7c065c317123c24f93987ee665 (diff)
downloadunits-6f5ae98c0ba75b220eb6ef4b0e8bbc8cc27af9f8.tar.xz
systemunit.pas: shellSubst kann nun auch explizit eine andere env verwenden
-rw-r--r--systemunit.pas19
1 files changed, 15 insertions, 4 deletions
diff --git a/systemunit.pas b/systemunit.pas
index f511f87..408fc19 100644
--- a/systemunit.pas
+++ b/systemunit.pas
@@ -12,7 +12,7 @@ function numCpus: int64;
function momentanFreieCpus: int64;
function belegterSpeicher: int64;
function minCache: int64;
-function shellSubst(s: string): string;
+function shellSubst(s: string; env: tMyStringList = nil): string;
function homeVerzeichnis: string; overload;
function homeVerzeichnis(user: string): string; overload;
function shellExpand(s: string): string; overload;
@@ -125,15 +125,26 @@ begin
closeFile(f);
end;
-function shellSubst(s: string): string;
+function shellSubst(s: string; env: tMyStringList = nil): string;
var
- name: string;
+ name: string;
+ i: longint;
+ gefunden: boolean;
begin
result:='';
while pos('${',s)>0 do begin
result:=result+erstesArgument(s,'${',false);
name:=erstesArgument(s,'}',false);
- result:=result+getEnvironmentVariable(name);
+ gefunden:=false;
+ if assigned(env) then
+ for i:=0 to env.count-1 do
+ if leftStr(env[i],length(s)+1) = s+'=' then begin
+ result:=result+rightStr(env[i],length(env[i])-length(s)-1);
+ gefunden:=true;
+ break;
+ end;
+ if not gefunden then
+ result:=result+getEnvironmentVariable(name);
end;
result:=result+s;
end;