From 6f5ae98c0ba75b220eb6ef4b0e8bbc8cc27af9f8 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 9 Jan 2018 15:25:08 +0100 Subject: systemunit.pas: shellSubst kann nun auch explizit eine andere env verwenden --- systemunit.pas | 19 +++++++++++++++---- 1 file 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; -- cgit v1.2.3-70-g09d2