All of lore.kernel.org
 help / color / mirror / Atom feed
* [OT] Strange bash phenomenon
@ 2006-02-11 13:44 John A. Sullivan III
  2006-02-13 15:50 ` Pablo Sanchez
  0 siblings, 1 reply; 4+ messages in thread
From: John A. Sullivan III @ 2006-02-11 13:44 UTC (permalink / raw)
  To: Netfilter users list

Hello everyone.  This is a little off topic but I find it both
perplexing and amusing.  I've been spending the last few days enabling
support for CyberGuard security devices for the ISCS network security
management platform.  It has gone very well with the new firmware and
has given us a near off the shelf solution.

However, in one of the scripts for automated distribution of the rules,
it checks for the presence of existing iptables files.  I originally
thought I could do something like:

if [ -f iptables* ];then

But the shell expands all the iptables file names and creates an error
when passing that many arguments to the test.

So I then thought I could do:

FILES=/etc/config/iptables*
if [ -f ${FILES%% *} ];then
        cp /etc/config/iptables* /etc/config/PEPBackup/ 2>/dev/null
        if [ $? -ne 0 ]; then
                echo '[PEP Update Error]' Could not backup up PEP
configuration files >&2
                exit 1
        fi
fi

I'd trim off everything after the first space and test for that single
file.  However, it doesn't work.  ${FILES%% *} expands to include all
the file names.  On the other hand, the version below works!


FILES=$(echo /etc/config/iptables*)
if [ -f ${FILES%% *} ];then
        cp /etc/config/iptables* /etc/config/PEPBackup/ 2>/dev/null
        if [ $? -ne 0 ]; then
                echo '[PEP Update Error]' Could not backup up PEP
configuration files >&2
                exit 1
        fi
fi

Any ideas why the latter one works fine but the other does not? Just
curious - John
-- 
John A. Sullivan III
Open Source Development Corporation
+1 207-985-7880
jsullivan@opensourcedevel.com

If you would like to participate in the development of an open source
enterprise class network security management system, please visit
http://iscs.sourceforge.net



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-02-13 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-11 13:44 [OT] Strange bash phenomenon John A. Sullivan III
2006-02-13 15:50 ` Pablo Sanchez
2006-02-13 16:56   ` John A. Sullivan III
2006-02-13 18:07     ` Pablo Sanchez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.