PDA

View Full Version : [SOLVED] Bash command set giving unexpected results



jamesisin
January 12th, 2010, 09:04 AM
I am studying bash.

I understand that set is supposed to print (to screen) a list of variables and their values (similar to env which shows only exported variables).

If I run set on my Mac I see the expected results. Running env on the Mac or my Ubuntu machines (8.10 and 9.10) also returns the expected results.

However, running set on my Ubuntu machines yields what appears to be a script of some sort.

Can someone tell me what's going on?

DaithiF
January 12th, 2010, 09:25 AM
set also outputs any bash functions which have been defined. these will be displayed after the evironment variables. So maybe thats what you're seeing. if you do:

set | less
it will page the results for you, you will (probably) see environment variables first, then at the at end any bash functions that have been defined.

jamesisin
January 12th, 2010, 06:03 PM
You are correct.

Man, that's a lot of bash functions. I trust the book I'm reading will discuss enough to help me understand what that's all about.

sisco311
January 12th, 2010, 07:00 PM
You are correct.

Man, that's a lot of bash functions. I trust the book I'm reading will discuss enough to help me understand what that's all about.

Most of them are bash tab completion functions (/etc/bash_completion & /etc/bash_completion.d/*).

jamesisin
January 13th, 2010, 06:27 PM
Well, that's a little confusing. I thought bash had tab-completion built in. What extra help does it need that would require so much additional code?

sisco311
January 13th, 2010, 06:56 PM
Well, that's a little confusing. I thought bash had tab-completion built in. What extra help does it need that would require so much additional code?

Custom completion options for different commands. i.e. username completion for chown

http://www.debian-administration.org/article/An_introduction_to_bash_completion_part_1

jamesisin
January 15th, 2010, 01:05 AM
Thanks for that. Looks like good reading.

lavinog
January 15th, 2010, 04:59 AM
Imagemagik creates a bunch of them too.