Re: Script Help (Bash) SOLVED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



| > On Sat, Sep 28, 2013 at 6:21 AM, Frank Murphy <frankly3d@xxxxxxxxx>
| > 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@xxxxxxxxxx>

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.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux