Mailinglist Archive: opensuse-factory (648 mails)
| < Previous | Next > |
Re: [opensuse-factory] systemd (feature #310327)
- From: Anders Johansson <ajohansson@xxxxxxxxxx>
- Date: Thu, 4 Nov 2010 11:11:23 +0100
- Message-id: <201011041111.23514.ajohansson@xxxxxxxxxx>
On Wednesday 03 November 2010 23:03:41 Brandon Philips wrote:
I don't really like constructs like echo $foo | sed. Bash can usually do a
much better job on its own, as long as you don't need really complex things.
Please consider a construct like this instead
for i in /etc/tmpfiles.d/*; do
while read type file mode user group age; do
if [ ! $type ] || [ ! $file ]; then
echo "Error: no type or file"
echo $line
exit 1
fi
# do the work.....
done < $i
done
I'm also not sure why you allow multiple parameters when they look to be
mutually exclusive
Anders
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-factory+help@xxxxxxxxxxxx
Thoughts?[...]
#
# parse all of the tmpfiles configs
# example line:
# d /var/lock/subsys 0755 root root -
#
cat /etc/tmpfiles.d/* | sed -e '/^#.*$/d' -e '/^\s*$/d' | while read line;
do eval $(echo $line |\
sed -n
"s/\(.\)\s\(.*\)\s\(.*\)\s\(.*\)\s\(.*\)\s\(.*\)/type=\1\nfile=\2\nmode=\3
\nuser=\4\ngroup=\5\nage=\6/p")
if [ ! $type ] || [ ! $file ]; then
echo "Error: no type or file"
echo $line
exit 1
fi
[ $arg_create ] && create_item
[ $arg_remove ] && remove_item
[ $arg_clean ] && clean_item
done
I don't really like constructs like echo $foo | sed. Bash can usually do a
much better job on its own, as long as you don't need really complex things.
Please consider a construct like this instead
for i in /etc/tmpfiles.d/*; do
while read type file mode user group age; do
if [ ! $type ] || [ ! $file ]; then
echo "Error: no type or file"
echo $line
exit 1
fi
# do the work.....
done < $i
done
I'm also not sure why you allow multiple parameters when they look to be
mutually exclusive
Anders
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-factory+help@xxxxxxxxxxxx
| < Previous | Next > |