From: "John A. Sullivan III" <jsullivan@opensourcedevel.com>
To: Netfilter users list <netfilter@lists.netfilter.org>
Subject: [OT] Strange bash phenomenon
Date: Sat, 11 Feb 2006 08:44:52 -0500 [thread overview]
Message-ID: <1139665492.21361.37.camel@localhost> (raw)
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
next reply other threads:[~2006-02-11 13:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-11 13:44 John A. Sullivan III [this message]
2006-02-13 15:50 ` [OT] Strange bash phenomenon Pablo Sanchez
2006-02-13 16:56 ` John A. Sullivan III
2006-02-13 18:07 ` Pablo Sanchez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1139665492.21361.37.camel@localhost \
--to=jsullivan@opensourcedevel.com \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.