Gentoo Archives: gentoo-dev

From: Aron Griffis <agriffis@g.o>
To: gentoo-dev@g.o
Cc: carpaski@g.o
Subject: [gentoo-dev] interesting bit of bash
Date: Thu, 17 Jul 2003 02:18:10
Message-Id: 20030717021807.GA17747@time
1 I don't know if this would be useful to anybody, but while looking into
2 a bug, I came up with a method to determine what variables are set by a
3 file such as make.conf or /etc/conf.d/*
4
5 vars_in_file() {
6 local _file=$1
7 ( eval "`export | sed 's/-/+/'`" # need double-quotes
8 set -a # export all new vars
9 . $_file # load up the vars
10 export | sed -n 's/^declare -x \(.*\)=".*/\1/p' )
11 }
12
13 This function will list the variables set in a file, for example
14
15 $ vars_in_file /etc/make.conf
16 ACCEPT_KEYWORDS
17 CFLAGS
18 CHOST
19 CONFIG_PROTECT_MASK
20 CXXFLAGS
21 DISTCC_HOSTS
22 DISTDIR
23 FEATURES
24 GENTOO_MIRRORS
25 MAKEOPTS
26 PORTAGE_NICENESS
27 PORTDIR
28 USE
29
30 $ vars_in_file /etc/conf.d/net
31 gateway
32 iface_eth0
33
34 The listing should always be correct since the file is being interpreted
35 (and executed) by bash.
36
37 Aron
38
39 --
40 gentoo-dev@g.o mailing list