How to? Environment Variables changed

Oct 18, 2008
339
2
Hello

For the past day or so I been trying to track down an issue that does not seems to make any sense.

I just set up the git / shell environment – for the most part it seems like a collection of commands cobbled together with the bash shell

the shortcut to run the bash shell is

c:\windows\system32\cmd.exe /c ""c:\program files\git\bin\sh.exe" --login -i"

I also put this text into a btm file to I could run it from the tcmd / tcc

It seem to work ok – I would run the btm and a bash shell would start up and now having scope in my tcmd/tcc window.

I would run some command and also specify the (full) path to the windows editor that I use. It all seems to work ok. I then exited out of the git /sh and nothing I was typing at the tcc prompt was working. – It turns out that my path and pathenv vars reverted back to what they were before tcstart ran I have changes in the path (and pathext) each time tcstart runs. What is even more bizarre is that I had multiple tcc tabs open and they all were changed in the same way.

I tried everything I could think of – I used the “start” command, I uses “setlocal” and “endlocal” but nothing seemed to work.

The only thing that make any kind of sense is that bash shell is hacking with the internal pointer to the env block – this makes some what sense, since the way env vars in BASH are in unix format, ie

/c/program files/mystuff:/c/foo

not

c:\program files\mystuff;c:\foo


and I could see hacking with the pointer would make somewhat sense since the code would have to toggle back-and-forth when ever a command is executed from within bash

Has anyone seen this before?
 
May 20, 2008
11,401
99
Syracuse, NY, USA
1. Why are you using CMD to start bash? Your CMD is doing nothing but sit there until you exit bash ... then, because of the "/c", CMD exits. It would seem better to just execute (shortcut or BTM file)
Code:
"c:\program files\git\bin\sh.exe" --login -i

2. Every process (EXE) has it's own environment (or environment block, as you put it). It is quite difficult for an app (bash) to alter the environment of another app (say its parent or grandparent). That requires injecting code into the other app and I'm rather confident bash doesn't do that.

I suggest you get CMD out of the picture and see how it works then.
 
Oct 18, 2008
339
2
1. Why are you using CMD to start bash? Your CMD is doing nothing but sit there until you exit bash ... then, because of the "/c", CMD exits. It would seem better to just execute (shortcut or BTM file)
Code:
"c:\program files\git\bin\sh.exe" --login -i

2. Every process (EXE) has it's own environment (or environment block, as you put it). It is quite difficult for an app (bash) to alter the environment of another app (say its parent or grandparent). That requires injecting code into the other app and I'm rather confident bash doesn't do that.

I suggest you get CMD out of the picture and see how it works then.

I did remove cmd.exe and just executed the sh.exe directly ... but the condition still the same --- I am now trying a "start" cmd -- at first when I did this, i used the "/b" option -- this time I am going have it create a new window -- I still content there is some trickery with the env pointers -- the env vars were still changed even with the sequence

setlocal
sh.exe
endlocal
 
Similar threads
Thread starter Title Forum Replies Date
Peter Murschall v27.00.16/17: ENDLOCAL with exporting variables wipes out the complete Environment Support 2
Charles Dye Read-only environment variables wiped by SETLOCAL / ENDLOCAL Support 5
J Shell nesting level, and inherited environment variables Support 10
fpefpe Documentation environment variables Support 3
daniel347x How to get Take Command to read in all current system environment variables that CMD.EXE sees? Support 13
vefatica What environment variables does IDE need? Support 3
E Environment variables, set and input Support 2
T Is there a way to maintain the position in the environment list, while debugging? Support 10
D Unnecessary environment dependencies of TCC.EXE Support 3
T Portable Take Command installation for VDI environment Support 2
D v23 environment oddity Support 3
gschizas Take Command (Environment) doesn't show v2 ANSI colors Support 30
M Save the environment .. ;-) Support 2
J Set environment variable from stdout of command Support 3
nickles Passing a variable to a command w/o adding it to the local environment Support 7
vefatica Environment refresh? Support 0
rfaquino WAD Apparently a bug when expanding environment variable %ProgramFiles(x86) Support 2
B WAD environment variable in TCC.exe Support 2
SeoulBigChris Save Environment (Tabs) on Exit? Support 3
vefatica OT: Rex, how does CMD handle its environment? Support 0
M Updating environment variable from C++ fails erratically in version 14... Support 57
Frank problem with environment variable x86 vs. x64 Support 2
fpefpe volatile environment Support 5
D Environment in elevated process Support 1
Peter Bratton IDE environment window display Support 0
D Environment variable oddity Support 12
vefatica Got IDE's environment tab back Support 0
S blanks in environment variable paths Support 4
tinjaw Looking for best practice for custom environment on tabs Support 0
E Environment variable in tcmd.ini Support 14
I Environment variable in OPTION screen? Support 2
J trouble redirecting output to environment variable Support 7
S How to? best way to compose data for command to use out of presets/variables Support 1
Joe Caverly START Dialog usage of %_ variables Support 0
Joe Caverly Modified Variables in CMDebug/BDebugger Support 1
T How to? Show the values of batch variables on the TCC screen Support 21
J Escaped Characters and Variables Support 2
M Keywords for commands, functions, internal variables Support 3
D How to? How to show variables expanded in the log tab Support 3
U Variables _IFTP, _IFTPS: what about sftp connections? Support 2
M Verification re volatile variables... Support 41
Stefano Piccardi 14.01.33 unset doesn't complain about undefined variables Support 8
CWBillow Variables in shortcuts? Support 15
Frank WAD handling variables with $-prefix Support 14
cgunhouse Accessing variables set using SET /U or SET /S Support 3
G gosub variables Support 9
vefatica Leading spaces in array variables Support 13
T Elapsed time format in prompt changed in TCC 25 Support 10
nikbackm @isdigit behaviour changed Support 3
D Version 18 changed the naming convention of TC's folder Support 5

Similar threads