|
Subject: interesting bit of bash Newsgroups: gmane.linux.gentoo.devel Date: 2003-07-17 02:18:08 GMT (5 years, 13 weeks, 12 hours and 49 minutes ago)
I don't know if this would be useful to anybody, but while looking into
a bug, I came up with a method to determine what variables are set by a
file such as make.conf or /etc/conf.d/*
vars_in_file() {
local _file=$1
( eval "`export | sed 's/-/+/'`" # need double-quotes
set -a # export all new vars
. $_file # load up the vars
export | sed -n 's/^declare -x \(.*\)=".*/\1/p' )
}
This function will list the variables set in a file, for example
$ vars_in_file /etc/make.conf
ACCEPT_KEYWORDS
CFLAGS
CHOST
CONFIG_PROTECT_MASK
CXXFLAGS
DISTCC_HOSTS
DISTDIR
FEATURES
GENTOO_MIRRORS
MAKEOPTS
PORTAGE_NICENESS
PORTDIR
USE
$ vars_in_file /etc/conf.d/net
gateway
iface_eth0
The listing should always be correct since the file is being interpreted
(and executed) by bash.
Aron
--
gentoo-dev <at> gentoo.org mailing list
|
|
|