public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Roy Marples <uberlord@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev]  Re: Re: Re: [gentoo-commits] gentoo-x86 commit in dev-php5/onphp: ChangeLog onphp-0.10.6.ebuild onphp-0.10.4.ebuild onphp-0.10.3.ebuild
Date: Tue, 16 Oct 2007 15:08:16 +0100	[thread overview]
Message-ID: <1192543696.1173.18.camel@uberlaptop.development.ltl> (raw)
In-Reply-To: <ff2b49$v28$1@ger.gmane.org>

On Tue, 2007-10-16 at 13:38 +0100, Steve Long wrote:
> Roy Marples wrote:
> > On Tue, 2007-10-16 at 00:28 -0700, Donnie Berkholz wrote:
> >> On 08:19 Tue 16 Oct     , Steve Long wrote:
> >> > stdDocs=(ChangeLog AUTHORS FEATURES THANKS README CodingStyle TODO FAQ)
> >> > 
> >> > stdDoc() {
> >> >         local d l=()
> >> >         for d in "${stdDocs[@]}"; do
> >> >                 [[ -f $d ]] && l+=("$d")
> >> >         done
> >> >         ((${#l[@]})) && dodoc "${l[@]}"
> >> > }
> >> > 
> >> > (assuming [[ $PWD = $S ]] or whichever is the right one for docs.)
> >> 
> >> Is it just me, or is this code way more complex than it needs to be? It
> >> looks like bashturbation to me. =P
> >
> LMAO. It's as complex as it needs to be to handle filenames with spaces or
> any other character in. Remember: "Looks like it needs quotes there.. $D,
> $S.." What, I should write crap script for this esteemed audience, cos you
> only currently deal with filenames without spaces? ;P

No, it's overly complex. Consider this

stddoc() {
   local d
   for d in ChangeLog AUTHORS FEATURES THANKS README \
      CodingStyle TODO FAQ; do
      [ -f "${d}" ] && dodoc "${f}"
   done
}

Want spaces?

stddoc() {
   local d
   for d in ChangeLog AUTHORS FEATURES THANKS README \
      CodingStyle TODO FAQ "a file with spaces"; do
      [ -f "${d}" ] && dodoc "${f}"
   done
}

Or maybe you want to do it on one hit?

stddoc() {
   local d
   set --
   for d in ChangeLog AUTHORS FEATURES THANKS README \
      CodingStyle TODO FAQ "a file with spaces"; do
      [ -f "${d}" ] && set -- "$@" "${f}"
   done
   dodoc "$@"
}


> > You can also do some pattern matching like so
> > 
> > foo="foo foobar"
> > 
> > [ "${foo%foobar}" = "${foo}" ] || echo "ends with foobar"
> [[ $foo = *foobar ]] && echo "ends with foobar"
> 
> > [ "${foo#foobar}" = "${foo}" ] || echo "starts with foo"
> [[ $foo = foo* ]] && echo 'oh does it?'
> There's no need for borked script that is counter-intuitive, and doesn't
> have a third of the functionality either.

I maybe wrong, but shouldn't you be using == inside [[ ]]?

> [[ $foo = *'wow it '*"does as $well"* ]] && echo 'And a whole lot more!'

case "${foo}" in
   *'wow it '*"does as $well"*) && echo "whatever you can do i can do in
sh";;
esac

>  Or should *nix only ever support
> POSIX APIs for everything? #define _X_OPEN_SOURCE? No? Hmm.. *shrug* ;>

No, I saying use whatever god given extensions you like. But if there's
a portable way of doing the same thing then please use the portable way
of doing it.

> /me wanders down the pub.. *plop*

Yeah, I'd drown my sorrows if I wrote shell script like you :P

Thanks

Roy

-- 
gentoo-dev@gentoo.org mailing list



  reply	other threads:[~2007-10-16 14:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Ih7qa-0007Zq-2s@stork.gentoo.org>
2007-10-14 21:11 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in dev-php5/onphp: ChangeLog onphp-0.10.6.ebuild onphp-0.10.4.ebuild onphp-0.10.3.ebuild Donnie Berkholz
2007-10-14 22:12   ` Konstantin V. Arkhipov
2007-10-14 23:52   ` Drake Wyrm
2007-10-15  0:18     ` Donnie Berkholz
2007-10-15  0:25     ` Thomas de Grenier de Latour
2007-10-16  7:19       ` [gentoo-dev] " Steve Long
2007-10-16  7:28         ` Donnie Berkholz
2007-10-16  7:44           ` Roy Marples
2007-10-16 12:38             ` [gentoo-dev] " Steve Long
2007-10-16 14:08               ` Roy Marples [this message]
2007-10-17  9:15                 ` [gentoo-dev] " Steve Long
2007-10-17 11:26                   ` Roy Marples
2007-10-18  2:15                     ` [gentoo-dev] " Steve Long
2007-10-18  9:39                       ` Marius Mauch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1192543696.1173.18.camel@uberlaptop.development.ltl \
    --to=uberlord@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox