nasty env vars
Manage your shell environment variables and aliases
Brought to you by:
leomania,
xdelaruelle
From: Mark L. <la...@mi...> - 2002-04-10 00:34:21
|
We have one piece of software that requires a nasty env var to be set. The environment variable contains double-quotes and curly braces, for example: BEGIN{require"/foo/init.pl"} (perl hackers will recognize that as perl syntax. Don't ask me who decided to store a perl one-liner in an env var!) In csh, you can set it with setenv FOO 'BEGIN{require"/foo/init.pl"}' However, you will be hardpressed to get this to work in a module! Try it! The double quotes and the curly braces will ruin your day, so if you tried that line "as is" in your modulefile, you will get BEGINrequire/foo/init.pl as the env var! This is because of several levels of evals and backticks that process the line. The curly braces are csh syntax for filename substitution, so they get erased. The quotes get erased too. The other problem is that you can't nest quotes like ' or ", and you can't escape " inside a string, only outside a string (unlike C syntax). You can turn off the {} mangling by using 'set noglob' in csh, but you have to 'set noglob' on a different line than the one your are parsing, and eval only accepts one liners! eg #this works eval set noglob eval setenv FOO BEGIN{require\"/foo/init.pl\"} # this doesn't eval "set noglob; setenv FOO BEGIN{require\"/foo/init.pl\"}" ARGH! I've tried all manner of quoting levels, only to really tear my hair out. At some point I got to setenv FOO {'"BEGIN{require"\\\"/foo/init.pl\\\""}"'} which almost worked, but it doesn't. Also, anything that I could kinda make work would break all the other shell syntaxes. Any Ideas? -Mark Mark Lakata, Staff Engineer 1225 Charleston Road voice 650-567-5170 MIPS Technologies Mountain View CA 94043 fax 650-567-5002 |