Date: Sun, 9 Nov 2008 09:01:32 +0100 From: Polytropon <freebsd@edvax.de> To: Jeremy Chadwick <koitsu@freebsd.org> Cc: freebsd-questions@freebsd.org, Jonathan McKeown <jonathan+freebsd-questions@hst.org.za> Subject: Re: eps to jpg conversion - which program? 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%2Bfreebsd-questions@hst.org.za> <20081109072549.7272df20.freebsd@edvax.de> <20081109073632.GA32503@icarus.home.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 8 Nov 2008 23:36:32 -0800, Jeremy Chadwick <koitsu@freebsd.org> 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. > <style-rant> > 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 <native-perl-code> > 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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081109090132.bb4b8881.freebsd>