From owner-freebsd-questions@FreeBSD.ORG Sun Nov 9 08:01:37 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B4481065676; Sun, 9 Nov 2008 08:01:37 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 0040A8FC16; Sun, 9 Nov 2008 08:01:36 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r55.edvax.de (port-92-196-88-233.dynamic.qsc.de [92.196.88.233]) by mx01.qsc.de (Postfix) with ESMTP id ABEB950BB3; Sun, 9 Nov 2008 09:01:33 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id mA981WZK002975; Sun, 9 Nov 2008 09:01:32 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Sun, 9 Nov 2008 09:01:32 +0100 From: Polytropon To: Jeremy Chadwick Message-Id: <20081109090132.bb4b8881.freebsd@edvax.de> In-Reply-To: <20081109073632.GA32503@icarus.home.lan> References: <49143663.9070804@shopzeus.com> <20081107201954.5d7e4993.freebsd@edvax.de> <200811081212.46286.jonathan+freebsd-questions@hst.org.za> <20081109072549.7272df20.freebsd@edvax.de> <20081109073632.GA32503@icarus.home.lan> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org, Jonathan McKeown Subject: Re: eps to jpg conversion - which program? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2008 08:01:37 -0000 On Sat, 8 Nov 2008 23:36:32 -0800, Jeremy Chadwick wro= te: > Also, what guarantee do you have that all the filenames that match that > wildcard lack spaces in them? Your [ and convert commands will botch > badly in that case. See below. This is completely correct. If files are present as foo.EPS, the "Windows" style of file naming, or foo.Eps in a mixed form, the *.eps wouldn't catch it. As you mentioned, it's good to assume the worst case. Not only spaces, as well special characters. Now *that's* the real fun. :-) John@Foobar sent me | Copy [5] of C:\My Files\A&V with =F6 and =DF.Eps Another mentionable comment would be: "Why do you call the variable just $f? Give it a better descriptive name." In this small example, it won't lead into significant problems if you don't do it, but I've seen shellscripts using $f, $f1, $f2, $g, $h, $y all over the file, and it was hard to find out which values they should hold. > > What people often forget while writing sh scripts is that spawning > external utilities slows down the script greatly, and destroys system > resources. You might think "My machine has 923484390GB of RAM, and has > 6500 processors; why do I care?" -- step back for a moment and think > about older/smaller boxes, or even more importantly, embedded machines > (very little memory, very little CPU). Hey, that's how software development helps hardware development, or at least software development in Redmond. :-) Hardware ressources ++ Overall usage speed =3D ------------------------ =3D const. Software requirements ++ q.e.d. > Also think about situations where fork() will fail due to resource > limits or existing system resource exhaustion; what then? I see this > regularly in perl scripts; people relying on `xxx` for no good reason. > I ask them, "Why are you doing this? Can you not use > instead, and avoid wasting resources and excessive risk?", and they > often have no idea what I'm talking about. And whenever I see `ssh > user@host "command"` in perl scripts, I cry. Ooow! Is this for real? If it is, it's a reason to hit someone's head with the keyboard. :-) > That in mind, don't let your scripting mimic that of "perl bastards" who > *intentionally* write obfuscated code just to "show off" (often citing > "its faster" as the reason, choosing to intentionally ignore that perl > is a compiled language). For complex pieces of sh that are hard to > visually parse: try to keep it simple, and take the time to write > decent/legible comments above the hairy part of the script. Indentation, comments and descriptive identifiers help a lot. If you read FreeBSD's (scripting) sources, you'll see that they are of high quality. > Also remember that double-quoting filenames or variables that are used > as filenames is a VERY good idea. Filenames with spaces are quite > common these days. It's best to assume the worst, but not be *too* > over-zealous. Especially when you're intending to use a piece of software, even if it's just a three line shell script, more than just one time, or if you want to share it with others. --=20 Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...