Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to set an ENV variable for just one shell command (ie make it expire right after the command executes)?

For example:

export VERSIONER_PYTHON_PREFER_32_BIT=yes
winpdb

I'd like to set my system to use 32bit Python for just this command, then go back to 64bit. Maybe something like

VERSIONER_PYTHON_PREFER_32_BIT=yes; winpdb

Thanks!

share|improve this question
    
The [python] tag should only be used when the question directly relates to Python (e.g. it is written in Python). The same idea applies to tags in general. –  Josh Sep 9 '10 at 20:45
    
I think the [shell] tag should be more specific ([bourne-shell] I assume). –  Josh Sep 9 '10 at 20:46

3 Answers 3

up vote 8 down vote accepted

in Bash, you can do VERSIONER_PYTHON_PREFER_32_BIT=yes winpdb and the env variable is set for the command. Same as you propose but without semi-colon.

share|improve this answer
    
There's also the "env" command, which exists for exactly this purpose. But yes, if you're already at a shell prompt, it's easier to just to "ENV=foo cmd". –  Teddy Oct 24 '09 at 21:40

Run it in a subshell. so (export VERIONSER_PYTHONG_PREFER_32_BIT=YES; winpdb)

share|improve this answer

Put parenthesis around the command:

(export VARNAME=value; cmd1; cmd2; cmd3)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.