Unix questions - Is there an "undo" for export at the end of a shell script?

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > February 2005 > Is there an "undo" for export at the end of a shell script?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Is there an "undo" for export at the end of a shell script?
Ulf Meinhardt

2005-02-17, 5:54 pm

Assume I change an environment variable at the beginning of a shell script e.g.

export BLA=myval:$BLA

Notice that $BLA already exists and has an unknown content. How do I switch back
to the original value at the end of the shell execution?

At a first glance I could store the initial value in a local variable:

savebla=$BLA
export BLA=myval:$BLA
.....
....other manipulations of $BLA
.....
(*1)
.....
export BLA=$savebla
exit


But what happens if the shell crashes at (*1) ?
The env variable has no chance to get back its original value.

Ulf

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com