ls colors - command substitution - mainly a bash question

Kevin Krumwiede krum at
Sun Jul 15 09:49:10 PDT 2001

I wanted to set ls colors automatically at each login by sourcing the output
of dircolors.  I tried to use command substitution to run the output of
dircolors, but it doesn't work.  I tried this:

# $(echo 'echo foo')

This prints 'foo'.  But this fails:

# $(dircolors /etc/DIR_COLORS)

Bash complains about LS_COLORS='<yadda yadda>' not being a valid command.
Bug or feature?  A similar thing happens if you try to set a variable by
running a command contained in a variable:

# FOO='BAR=baz'
# $FOO

This obviously works:

# dircolors /etc/DIR_COLORS > setcolors; source setcolors

...but I don't like it.  I ended up adding the output of dircolors to my
.bashrc, but I'm still curious as to why command substitution doesn't work


Unsubscribe: send email to lfs-discuss-request at
and put unsubscribe in the subject header of the message

More information about the lfs-dev mailing list