| > On Sat, Sep 28, 2013 at 6:21 AM, Frank Murphy <frankly3d(a)gmail.com>
| > wrote: [...]
| > > #!/bin/bash
Unless I really need bash, I use:
#!/bin/sh
More portable. You'll be surprised how little bash actually gives
you in scripting scenarios.
| > > ## Download no-bebug rawhide kernel
| > > /usr/bin/cd
/var/cache/yum/x86_64/20/fedora-rawhide-kernel-nodebug-source/packages
| > > && \ /usr/bin/reposync --source -n =fedora-rawhide-kernel-nodebug
| > > kernel && \
Two remarks:
I tend to write lines like the above as:
cmd1 \
&& cmd2
If you write:
cmd1 && \
cmd2
and accidentally put something after the slosh (such as some
spaces), the former layout will cause a syntax error (alerting
you) while the latter layout will quietly not work quite as
expected.
Second:
I almost invariably put:
set -ue
at the top of my scripts. This turns on -u: abort on an undefined
variable, VERY handy for catching assignment mistakes and -e:
abort on error, which means abort when any command has a non-zero
exit status _that has not been checked_.
This would let you write your script like this:
set -ue
cd /var/cache/yum/x86_64/20/fedora-rawhide-kernel-nodebug-source/packages
/usr/bin/reposync --source -n =fedora-rawhide-kernel-nodebug
and so on without all the tedious "&&" stuff.
It is surprisingly useful and easy to code under this regime,
and catches a long of simple mistakes.
Cheers,
--
Cameron Simpson <cs(a)zip.com.au>
Gross power consumption [...] such as 3D graphics and MPEG-2 are the
two applications which consume a disproportionate amount of power [...]
eating close to 18 watts of power. Close behind is Microsoft Word 7.0,
which consumes close to 16 watts of power.