Date: Tue, 6 Apr 1999 22:35:18 +0200 (CEST) From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de> To: freebsd-stable@FreeBSD.ORG Subject: Re: preventing periodic yossarian's syndrome Message-ID: <199904062035.WAA27862@dorifer.heim3.tu-clausthal.de>
next in thread | raw e-mail | index | archive | help
Randy Bush wrote in list.freebsd-stable: > for emacs users who get periodic yossarian's syndrome ("i see everything > twice!"), a hack on the order of the appended would be nice. though i hope > someone has a better way of doing the backticked expression. > [...] > ! if [ -x $file -a ! -d $file -a ! `echo $file | grep \~` ] ; then > $file > fi Just a suggestion: The following ist much more efficient, because "case" is a shell-builtin, therefore it saves several forks/execs. Also, "$file" should be enclosed in double quotes to protect it from the shell if it contains special characters. if [ -x "$file" -a ! -d "$file" ] ; then case "$file" in *~*) ;; *) "$file";; esac fi As a general rule of thumb, it's always better to use case instead of grep in shell scripts if a variable is to be compared against a pattern that can be expressed using shell globbing. This can give a significant speed-up, especially in loops. Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904062035.WAA27862>