Geek pop quiz:
Aug. 10th, 2011 05:21 pmIs there an easy way to tell where a Linux environment variable is set? Like, which config file it was in, when you've got an incestuously complicated set of sub-references and called files, and the normal "new user" script involves pulling in the entire bunch?
(Oh, and there's roughly 20TB of teeny little files where this COULD be set. So "grep -r VARIABLE=VALUE /*" will take months.)
.bashrc calls three other scripts, each of which call other scripts in turn, and it all works out... in practice. But we can't seem to find out WHERE one specific environment variable gets set.
EDIT: Brute force FTW. Comment out each line in turn until the variable stops being set. Follow that file. Repeat.
Only took about 30 minutes, versus grep.
EDIT2: Oh, and if I *had* run that grep command, that would have totally sucked for me when, in October, I got my results and it had no useful lines in it - because "/*" will ignore hidden files. I more wanted "/.*", or maybe even "/\.*". The second is less thorough but would have worked since it *was*, finally, set in a .file.
(Oh, and there's roughly 20TB of teeny little files where this COULD be set. So "grep -r VARIABLE=VALUE /*" will take months.)
.bashrc calls three other scripts, each of which call other scripts in turn, and it all works out... in practice. But we can't seem to find out WHERE one specific environment variable gets set.
EDIT: Brute force FTW. Comment out each line in turn until the variable stops being set. Follow that file. Repeat.
Only took about 30 minutes, versus grep.
EDIT2: Oh, and if I *had* run that grep command, that would have totally sucked for me when, in October, I got my results and it had no useful lines in it - because "/*" will ignore hidden files. I more wanted "/.*", or maybe even "/\.*". The second is less thorough but would have worked since it *was*, finally, set in a .file.
(no subject)
Date: 2011-08-10 09:31 pm (UTC)HTH, HAND.
(no subject)
Date: 2011-08-10 09:45 pm (UTC)I dare say you could do this with a programming IDE reasonably easily.
(no subject)
Date: 2011-08-10 09:47 pm (UTC)(no subject)
Date: 2011-08-10 09:53 pm (UTC)I assume you want to change the value of it, and have tried just updating the variable again where you do have control?
I know its messy, but really the best way of dealing with this is letting a software dev have a go imo.
(no subject)
Date: 2011-08-11 02:32 am (UTC)Why yes! That works just fine!
The problem is this: Changing which project you're working on sets a pile of environment variables, using a project-specific script. This is all done with a simple script, "local projectname", which runs the project-specific script *and* a bunch of other cleanup things and makes sure everything is set right.
One project needs this variable to change. The problem is, while the project-specific script (project.sh) sets the variable and it works if you run that manually, if you set the project the way you set ALL OTHER PROJECTS that variable is overridden in a place we couldn't find.
(and yes, this is much more information than the original post had. This is because I learned all this information while digging in to try to find the problem - the original problem description I got was... lacking.)
(no subject)
Date: 2011-08-10 09:50 pm (UTC)(no subject)
Date: 2011-08-10 10:42 pm (UTC)(no subject)
Date: 2011-08-11 12:02 am (UTC)(no subject)
Date: 2011-08-11 12:05 am (UTC)(no subject)
Date: 2011-08-10 09:53 pm (UTC)(no subject)
Date: 2011-08-11 02:33 am (UTC)(no subject)
Date: 2011-08-15 01:13 pm (UTC)(no subject)
Date: 2011-08-15 01:27 pm (UTC)This is a computer with a monstrously huge 20TB "drive" on a NAS. And the files in question are definitely not in /etc/, because that's local and the files are not stored locally per-machine.
(no subject)
Date: 2011-08-10 10:20 pm (UTC)pf dogcow@veal: ~/bin 3266 % zsh -x /etc/rc |& head
+/home/dogcow/.zshenv:4> export 'CVS_RSH=ssh'
+/home/dogcow/.zshenv:6> [ -n 78592.ttyp2.veal ']'
+/home/dogcow/.zshenv:12> export 'FTP_PASSIVE=1'
+/home/dogcow/.zshenv:14> [ -n '' ']'
+/etc/rc:41> stty status '^T'
+/etc/rc:46> trap : 2
+/etc/rc:47> trap 'echo '\''Boot interrupted'\''; exit 1' 3
Re: EDIT2
Date: 2011-08-11 06:05 am (UTC)Re: EDIT2
Date: 2011-08-11 12:12 pm (UTC)