Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I accidentally typed the command export into my console emulator (running Bash) instead of export -p, and now all the bash_completion scripts are persistently in my environment, even surviving reboot. I'd like to undo that but haven't been able to figure it out after some hours. I got as far as finding them in /etc/bash.bashrc but don't see what is sourcing that, and in any case still can't figure out how or why export with no args can do such damage.

This is under Knoppix, in the non-root knoppix account. When I su - the root account has no such problem.

[update: I don't know what I'm talking about. By "environment" I meant the output of the set Bash builtin, which was where the functions were showing. I should be using env. Anyway, what happened was that I have been using set in my Makefiles to test the generation of certain values, and I was surprised to suddenly see all those functions in the output. Then after reboot I checked from the command line and still saw them, not thinking to check from the Makefile (from which they no longer show, not being exported. So, problem solved; they were obviously in my set output all along, just hadn't noticed them before until accidentally typing export and seeing them in my make set output. Still it seems there's a mismatch in the documentation of bash to the behavior; export with no names is supposed to return a list of exported variables, not export everything.)]

share|improve this question
    
Have you checked /etc/profile and /etc/profile.d ? –  Joel Davis Apr 12 '13 at 13:31
    
I had checked /etc/profile before; just checked /etc/profile.d/ and found bash_completion.sh, thanks! but stat shows it's been there all along, and set didn't show the scripts until after the export. weird. –  jcomeau_ictx Apr 12 '13 at 14:03
    
You may want to add it as an answer to this post and accept it so that people know the question's dead. –  Joel Davis Apr 12 '13 at 14:27
    
What do you mean by “in my environment”? An environment doesn't contain scripts. Do you mean that the completion scripts are in your PATH? Or if you did mean environment variables, what variables are you talking about? Just what is the undesired behavior there: tell us a specific command, what it produces, and what it should do instead. –  Gilles Apr 12 '13 at 22:07

1 Answer 1

up vote 1 down vote accepted

You can list all your variables with env and use unset $VARIABLE to remove all unnecessary variables from your environment and thus fix your problem. You have to be careful to unset the right variables, because if you unset your PATH, for example, you won't be able to run any commands/applications.

While this doesn't explain what went wrong with your bash_completion scripts, it would undo the accidental export.

share|improve this answer
    
I did that before posting the question, but on reboot they were all back again. –  jcomeau_ictx Apr 12 '13 at 14:00
    
since you're the only one who "answered" I'll give you the credit, especially since you reminded me about the use of env to show the true environment variables rather than using set. there's still so much about unix I'm really vague about :^\ –  jcomeau_ictx Apr 13 '13 at 22:01

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.