Summary: | if.. then vs. if... <nl> then | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Mark Dominik Bürkle <dominik.buerkle> |
Component: | [OLD] Core system | Assignee: | SpanKY <vapier> |
Status: | VERIFIED INVALID | ||
Severity: | normal | CC: | radek |
Priority: | High | ||
Version: | 2005.0 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Mark Dominik Bürkle
2005-05-10 03:06:27 UTC
Hi SpanKY, btw. thanks for all the work You do!! But I see no reason to change sth. like - if [ -e /etc/conf.d/local.stop ] - then + if [[ -e /etc/conf.d/local.stop ]] ; then either, as "[[ ... ]]" in this case just will not do word splitting and filename expansion (and more?), which would not occur anyways because there are no variable parts in this file name, and I find it much clearer to write if test -e "$somefileVar"; then instead of if [[ -e $somefileVar ]] Though the latter nicely shows the capabilities of bash, putting "" around filename variables will work everywhere... but it doesn't make a difference here. +# $Header: /var/cvsroot/gentoo-src/rc-scripts/init.d/localmount,v 1.29.4.2 2005/02/19 19:47:53 vapier Exp $ ... + local usbfs=$(grep -Fow usbfs /proc/filesystems || + grep -Fow usbdevfs /proc/filesystems) ... + if [[ -n ${usbfs} ]] && \ + [[ -e /proc/bus/usb && ! -e /proc/bus/usb/devices ]] You might as well be interested in grep's "-q / --quiet" option, which does not output anything... though in this case You certainly want output. Consider combining multiple grep searches into one with "-e ... -e ...", as this would be two less fork()/exec()s in this case -- doesn't matter on todays hardware, but on some old 486 (or even 386) all those expenses will sure hurt performance: local usbfs=$(grep -Fow usbfs /proc/filesystems || grep -Fow usbdevfs /proc/filesystems) => local usbfs=$(grep -owe usbfs -e usbdevfs /proc/filesystems) or local usbfs=$(grep -owEe 'usb(dev)?fs' /proc/filesystems) And maybe (though there should only be one of them in /proc/filesystems) a combination with "-m 1"... but I'm getting way too deep into it. Regards, Dominik Hi, if this is going to be an argument, my opinion is to keep the "then" on the same line :-) ive never written code of the form if ... then regardless, see the STYLE file in baselayout thanks for the hint, but I didn't find "style" in baselayout: equery files baselayout | while read f rest; do test -L "$f" -o -d "$f" && continue test ! -e "$f" && continue echo "$f" done | xargs -r grep -i --color=tty -e style Would You mind to give me another hint? No matter if You do: thanks, sorry to take Your time! Dominik closing bug, may be purged from the DB. (New status should be closed invalid.) |