Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-18 Thread Michał Górny
On Wed, 13 Oct 2010 17:46:43 -0400
Mike Frysinger vap...@gentoo.org wrote:

 On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
  And why putting different tasks into one function?
 
 for the same reason we dont have separate test binaries: test_exist, 
 test_file, test_dir, etc...
 
 it makes more sense in my mind to combine the functionality.

And we finally reach the point where there is no reason to implement
a new function when it's supposed to be basically longer and more
unclear to use than:

[[ -f a || -f b || -f c ]]

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-18 Thread Mike Frysinger
On Monday, October 18, 2010 03:08:15 Michał Górny wrote:
 On Wed, 13 Oct 2010 17:46:43 -0400 Mike Frysinger wrote:
  On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
   And why putting different tasks into one function?
  
  for the same reason we dont have separate test binaries: test_exist,
  test_file, test_dir, etc...
  
  it makes more sense in my mind to combine the functionality.
 
 And we finally reach the point where there is no reason to implement
 a new function when it's supposed to be basically longer and more
 unclear to use than:
 
 [[ -f a || -f b || -f c ]]

except that we're using globs, so our example isnt applicable.
[[ -f */a ]]
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-18 Thread Mike Frysinger
On Monday, October 18, 2010 14:06:26 Mike Frysinger wrote:
 On Monday, October 18, 2010 03:08:15 Michał Górny wrote:
  On Wed, 13 Oct 2010 17:46:43 -0400 Mike Frysinger wrote:
   On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
And why putting different tasks into one function?
   
   for the same reason we dont have separate test binaries: test_exist,
   test_file, test_dir, etc...
   
   it makes more sense in my mind to combine the functionality.
  
  And we finally reach the point where there is no reason to implement
  a new function when it's supposed to be basically longer and more
  unclear to use than:
  
  [[ -f a || -f b || -f c ]]
 
 except that we're using globs, so our example isnt applicable.

err, our - your
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-18 Thread Michał Górny
On Mon, 18 Oct 2010 14:06:26 -0400
Mike Frysinger vap...@gentoo.org wrote:

 On Monday, October 18, 2010 03:08:15 Michał Górny wrote:
  On Wed, 13 Oct 2010 17:46:43 -0400 Mike Frysinger wrote:
   On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
And why putting different tasks into one function?
   
   for the same reason we dont have separate test binaries:
   test_exist, test_file, test_dir, etc...
   
   it makes more sense in my mind to combine the functionality.
  
  And we finally reach the point where there is no reason to implement
  a new function when it's supposed to be basically longer and more
  unclear to use than:
  
  [[ -f a || -f b || -f c ]]
 
 except that we're using globs, so our example isnt applicable.
   [[ -f */a ]]

Ok. So, let's sum up what your function does with wildcards:

1) when passed a single wildcard, the OR and AND variants basically do
the same (unless one of the matched files disappears during the
check), so their co-existence is useless in that case.

2) When passed multiple wildcards (or a wildcard and filenames), these
variants indeed are both useful but the AND variant does unnecessary
amount of checking (checking each filename matched by each wildcard)
and is fragile to a single matched file disappearing during the runtime.

So, it's basically safer to use:

if path_exists -o a/*  path_exists -o b/*; then
...
fi

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-17 Thread Mike Frysinger
On Wednesday, October 13, 2010 19:08:55 Amadeusz Żołnowski wrote:
 Excerpts from Mike Frysinger's message of Thu Oct 14 00:32:40 +0200 2010:
  On Wednesday, October 13, 2010 18:13:18 Amadeusz Żołnowski wrote:
   Mike Frysinger's message of Wed Oct 13 23:46:43 +0200 2010:
On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
 And why putting different tasks into one function?

for the same reason we dont have separate test binaries: test_exist,
test_file, test_dir, etc...

it makes more sense in my mind to combine the functionality.
   
   So the only argument for having more complicated, less intuitive and
   less readable function is the old 'test' program?  Please, reconsider
   my solution with more reason.
  
  we prioritize differently.  i prefer unified code with options.
 
 In which part it's unified?

the file checking  status accumulation.  extending my code to add more 
options in the future is easier as well.

 As I said it doesn't conform much to 'test' convention.

sure it does

this thread is going nowhere.  i believe my proposal is the way to go, and we 
arent arguing over anything of too much value (i.e. bike shedding).  no one 
else has an opinion, so ive gone my route.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-17 Thread Mike Frysinger
On Tuesday, October 12, 2010 16:09:06 Dirkjan Ochtman wrote:
 On Fri, Oct 1, 2010 at 15:07, Peter Volkov p...@gentoo.org wrote:
if [[ -n $(ls /etc/openvpn/*/local.conf 2/dev/null) ]] ; then
  
  I'd suggested [ -e /etc/openvpn/*/local.conf ] here, but probably there
  are better alternatives. Also ${ROOT} is missed here.
 
 I've put ${ROOT} in, are there no better alternatives? I don't think
 anyone mentioned any.

please to convert to new eutils.eclass:path_exists()
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-17 Thread Amadeusz Żołnowski
Excerpts from Mike Frysinger's message of Sun Oct 17 23:33:57 +0200 2010:
 On Wednesday, October 13, 2010 19:08:55 Amadeusz Żołnowski wrote:
  Excerpts from Mike Frysinger's message of Thu Oct 14 00:32:40 +0200 2010:
   On Wednesday, October 13, 2010 18:13:18 Amadeusz Żołnowski wrote:
Mike Frysinger's message of Wed Oct 13 23:46:43 +0200 2010:
 On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
  And why putting different tasks into one function?
 
 for the same reason we dont have separate test binaries: test_exist,
 test_file, test_dir, etc...
 
 it makes more sense in my mind to combine the functionality.

So the only argument for having more complicated, less intuitive and
less readable function is the old 'test' program?  Please, reconsider
my solution with more reason.
   
   we prioritize differently.  i prefer unified code with options.
  
  In which part it's unified?
 
 the file checking  status accumulation.  extending my code to add more 
 options in the future is easier as well.

The name doesn't allow for any sensible extension.  I'd advise to change
it to 'mtest' (which would stand for multiple test) or something like
that and give up default behaviour.  OK, and then your /options way/
starts to make sense. (Although status accumulation has still no benefit
here.)

Having such an 'mtest' we might use it in following way:

mtest -[oa] -[fredcw...] path1 path2 ... pathn

And stil we can do it simpler:

mtest() {
local f log_op=$1 test_op=$2; shift 2

case $log_op in
-a) for f; do
eval [[ $test_op '$f' ]] || return 1
done
return 0
;;
-o) for f; do
eval [[ $test_op '$f' ]]  return 0
done
return 1
;;
esac
return -1
}


– it's just a rough draft, proof of concept.  You've already gone your
way…


 this thread is going nowhere.  i believe my proposal is the way to go, and we 
 arent arguing over anything of too much value (i.e. bike shedding).  no one 
 else has an opinion, so ive gone my route.


Cheers,
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 04:23:16 Amadeusz Żołnowski wrote:
 Excerpts from Mike Frysinger's message of Tue Oct 12 22:57:11 +0200 2010:
  On Tuesday, October 12, 2010 16:26:31 Jeroen Roovers wrote:
   On Tue, 12 Oct 2010 22:09:06 +0200 Dirkjan Ochtman wrote:
On Fri, Oct 1, 2010 at 15:07, Peter Volkov wrote:
 [a very thorough review of the openvpn ebuild]

Thanks for reviewing, I've fixed most of the issues.

   if [[ -n $(ls /etc/openvpn/*/local.conf 2/dev/null) ]] ;
 
 then
 
 I'd suggested [ -e /etc/openvpn/*/local.conf ] here, but probably
 there are better alternatives. Also ${ROOT} is missed here.

I've put ${ROOT} in, are there no better alternatives? I don't think
anyone mentioned any.
   
   for foo in ${ROOT}/etc/openvpn/*/local.conf; do
   
   [ -e ${foo} ]  bar ${foo}
   
   done
   
   If no ${ROOT}/etc/openvpn/*/local.conf is found, it returns the exact
   string; which doesn't exist so Nothing Happens.
  
  i'd say doing a loop is worse than a `ls` hack.  and this has quoting
  problems, but that's ancillary ...
 
 What about defining following function?
 
 any_exists() {
 local f
 
 for f; do
 [[ -e $f ]]  return 0
 done
 
 return 1
 }

perhaps if it had a better name and were in a common location (eclass)
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 03:08:24 Vaeth wrote:
 Mike Frysinger wrote:
   for foo in ${ROOT}/etc/openvpn/*/local.conf; do
   
 [ -e ${foo} ]  bar ${foo}
   
   done
  
  i'd say doing a loop is worse than a `ls` hack.
 
 Why do you think so? No external program on which you must rely,
 and if you put a break in there, the loop is just syntactical.
 Here is another possibility if you do not need positional
 parameters anymore:
 
 set -- ${ROOT}/etc/openvpn/*/local.conf
 if test -e ${1}
 then ...
 fi
 
 And if you do need, you can write a function:
 
 Test2() {
   test ${1} ${2}
 }
 
 if Test2 -e ${ROOT}/etc/openvpn/*/local.conf
 then ...
 fi

relying on an external program to get a single line of readable code is better 
than multiple lines of code that attempt to do the same thing.  your further 
examples here are even worse on many levels.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Amadeusz Żołnowski
Excerpts from Mike Frysinger's message of Wed Oct 13 16:13:58 +0200 2010:
 On Wednesday, October 13, 2010 04:23:16 Amadeusz Żołnowski wrote:
  Excerpts from Mike Frysinger's message of Tue Oct 12 22:57:11 +0200 2010:
   On Tuesday, October 12, 2010 16:26:31 Jeroen Roovers wrote:
On Tue, 12 Oct 2010 22:09:06 +0200 Dirkjan Ochtman wrote:
 On Fri, Oct 1, 2010 at 15:07, Peter Volkov wrote:
  [a very thorough review of the openvpn ebuild]
 
 Thanks for reviewing, I've fixed most of the issues.
 
if [[ -n $(ls /etc/openvpn/*/local.conf 2/dev/null) ]] ;
  
  then
  
  I'd suggested [ -e /etc/openvpn/*/local.conf ] here, but probably
  there are better alternatives. Also ${ROOT} is missed here.
 
 I've put ${ROOT} in, are there no better alternatives? I don't think
 anyone mentioned any.

for foo in ${ROOT}/etc/openvpn/*/local.conf; do

[ -e ${foo} ]  bar ${foo}

done

If no ${ROOT}/etc/openvpn/*/local.conf is found, it returns the exact
string; which doesn't exist so Nothing Happens.
   
   i'd say doing a loop is worse than a `ls` hack.  and this has quoting
   problems, but that's ancillary ...
  
  What about defining following function?
  
  any_exists() {
  local f
  
  for f; do
  [[ -e $f ]]  return 0
  done
  
  return 1
  }
 
 perhaps if it had a better name and were in a common location (eclass)
 -mike

So give it a better name. :-)  In this case 'ls' shouldn't hurt anybody,
but such function solves problem in much more elegant manner -
regardless it's definied in an ebuild or eclass.
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Amadeusz Żołnowski
Excerpts from Michał Górny's message of Wed Oct 13 18:41:54 +0200 2010:
 On Wed, 13 Oct 2010 10:13:58 -0400
 Mike Frysinger vap...@gentoo.org wrote:
 
   any_exists() {
   local f
   
   for f; do
   [[ -e $f ]]  return 0
   done
   
   return 1
   }
  
  perhaps if it had a better name and were in a common location (eclass)
 
 has_file()?

What it would mean? „Has”?
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Michał Górny
On Wed, 13 Oct 2010 18:51:31 +0200
Amadeusz Żołnowski aide...@aidecoe.name wrote:

  has_file()?
 
 What it would mean? „Has”?

It's reference to has() function specified by PMS. 'The file system has
a file named one-of $...@}' :P.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 13:26:24 Michał Górny wrote:
 On Wed, 13 Oct 2010 18:51:31 +0200 Amadeusz Żołnowski wrote:
   has_file()?
  
  What it would mean? „Has”?
 
 It's reference to has() function specified by PMS. 'The file system has
 a file named one-of $...@}' :P.

the has functions are typically used to look up an item in a list.  i'd go 
with path_exists since this is doing -e and not -f.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 12:35:20 Vaeth wrote:
 Mike Frysinger wrote:
  relying on an external program
 
 The point is that external programs can have all sorts of undesired
 side effects. For instance, if an directory is not readable (or
 readable but not executable or is on $FILESYSTEM with who-knows-what
 permissions or accessability problems) it can cause unexpected
 errors which otherwise are treated  by standard shell behavior:
 *This* is why the ls is hackish here, not the readability.

and if you had read all my replies, you would see i already pointed out this 
problem with the original code

 but your attack is inappropriate:

might want to review the meanings of these words.  i said your examples were 
worse, not better.  i didnt say anything about you personally.

the rest of your e-mail isnt worth responding to, so i wont bother.  as most 
likely will any follow up to this.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
here's what i'll commit to eutils.eclass:

# @FUNCTION: path_exists
# @USAGE: [-a|-o] paths
# @DESCRIPTION:
# Check if the specified paths exist.  Works for all types of paths
# (files/dirs/etc...).  The -a and -o flags control the requirements
# of the paths.  They correspond to and and or logic.  So the -a
# flag means all the paths must exist while the -o flag means at least
# one of the paths must exist.  The default behavior is and.  If no
# paths are specified, then the return value is false.
path_exists() {
local opt=$1
[[ ${opt} == -[ao] ]]  shift || opt=-a

# no paths - return false
# same behavior as: [[ -e  ]]
[[ $# -eq 0 ]]  return 1

local p r=0
for p in $@ ; do
[[ -e ${p} ]]
: $(( r += $? ))
done

case ${opt} in
-a) return $(( r != 0 )) ;;
-o) return $(( r == $# )) ;;
esac
}
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Amadeusz Żołnowski
Excerpts from Mike Frysinger's message of Wed Oct 13 20:51:35 +0200 2010:
 path_exists() {
 local opt=$1
 [[ ${opt} == -[ao] ]]  shift || opt=-a
 
 # no paths - return false
 # same behavior as: [[ -e  ]]
 [[ $# -eq 0 ]]  return 1
 
 local p r=0
 for p in $@ ; do
 [[ -e ${p} ]]
 : $(( r += $? ))
 done

1) Why check every path in both and and or cases?

2) Even simpler:
for p; do
  [[ -e $p ]]
  ((r+=$?))
done

 
 case ${opt} in
 -a) return $(( r != 0 )) ;;
 -o) return $(( r == $# )) ;;
 esac
 }
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Ulrich Mueller
 On Wed, 13 Oct 2010, Mike Frysinger wrote:

 # If no paths are specified, then the return value is false.

For the or case that's fine. But for the and case, I would expect
that the function returns true if called with no arguments.

Ulrich



Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Amadeusz Żołnowski
Excerpts from Amadeusz Żołnowski's message of Wed Oct 13 21:20:01 +0200 2010:
 Excerpts from Mike Frysinger's message of Wed Oct 13 20:51:35 +0200 2010:
  path_exists() {
  local opt=$1
  [[ ${opt} == -[ao] ]]  shift || opt=-a
  
  # no paths - return false
  # same behavior as: [[ -e  ]]
  [[ $# -eq 0 ]]  return 1
  
  local p r=0
  for p in $@ ; do
  [[ -e ${p} ]]
  : $(( r += $? ))
  done
 
 1) Why check every path in both and and or cases?
 
 2) Even simpler:
 for p; do
   [[ -e $p ]]
   ((r+=$?))
 done
 
  
  case ${opt} in
  -a) return $(( r != 0 )) ;;
  -o) return $(( r == $# )) ;;
  esac
  }


And why putting different tasks into one function?  My suggestion:

any_paths() {
local f

for f; do
[[ -e $f ]]  return 0
done

return 1
}

all_paths() {
local f

for f; do
[[ -e $f ]] || return 1
done

return 0
}


Isn't it simpler approach?  And have benfits over 2in1:

1) More readable in use.
2) More efficient.
3) 1 + 1  2 in this case ;-)
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 15:37:02 Ulrich Mueller wrote:
  On Wed, 13 Oct 2010, Mike Frysinger wrote:
  # If no paths are specified, then the return value is false.
 
 For the or case that's fine. But for the and case, I would expect
 that the function returns true if called with no arguments.

i disagree as the comment says: it's sticking to the bash behavior.

f=
[[ -e ${f} ]]  [[ -e ${f} ]]
[[ -e ${f} ]] || [[ -e ${f} ]]

these both return false.  as does this function:

f=
path_exists -a ${f}
path_exists -o ${f}
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
 And why putting different tasks into one function?

for the same reason we dont have separate test binaries: test_exist, 
test_file, test_dir, etc...

it makes more sense in my mind to combine the functionality.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Amadeusz Żołnowski
Excerpts from Mike Frysinger's message of Wed Oct 13 23:46:43 +0200 2010:
 On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
  And why putting different tasks into one function?
 
 for the same reason we dont have separate test binaries: test_exist, 
 test_file, test_dir, etc...
 
 it makes more sense in my mind to combine the functionality.
 -mike

So the only argument for having more complicated, less intuitive and
less readable function is the old 'test' program?  Please, reconsider my
solution with more reason.  Moreover we're using 'test' as '[[ … ]]'
which changes much in readability.  Next thing is that '-a' and '-o'
don't strictly conform to 'test' convention.
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5


signature.asc
Description: PGP signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-13 Thread Mike Frysinger
On Wednesday, October 13, 2010 18:13:18 Amadeusz Żołnowski wrote:
 Excerpts from Mike Frysinger's message of Wed Oct 13 23:46:43 +0200 2010:
  On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
   And why putting different tasks into one function?
  
  for the same reason we dont have separate test binaries: test_exist,
  test_file, test_dir, etc...
  
  it makes more sense in my mind to combine the functionality.
 
 So the only argument for having more complicated, less intuitive and
 less readable function is the old 'test' program?  Please, reconsider my
 solution with more reason.

we prioritize differently.  i prefer unified code with options.  you preferred 
unrolled duplicated code.

 Moreover we're using 'test' as '[[ … ]]' which changes much in readability.

what are you talking about ?  no one is using `test` in their code and if they 
are, their code is broken.  none of the stuff ive posted is running `test`.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-04 Thread Jeroen Roovers
On Fri, 1 Oct 2010 20:47:38 +0530
Nirbheek Chauhan nirbh...@gentoo.org wrote:

                for i in $( ls 2/dev/null ); do

[...]

 A nice way around this is to do the following:
 
 ls -1 | while read i; do

What pva carelessly omitted to point out was that using ls(1) is
incredibly bad bash programming, which is probably why stderr is being
redirected in this case, too. :)


 jer



Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-01 Thread Thomas Sachau
Am 01.10.2010 15:07, schrieb Peter Volkov:
 В Пнд, 27/09/2010 в 11:37 +, Dirkjan Ochtman (djc) пишет:
 
  [[ ${i} == README || ${i} == examples || ${i} == 
 defer ]]  continue
  [[ ${i} == auth-pam ]]  ! use pam  continue
  einfo Building ${i} plugin
  cd ${i}
  emake CC=$(tc-getCC) || die make failed
  cd ..
 
 I think pushd/popd are better suited for this then cd ${dir} / cd ..
 

You can make it even shorter by using the -C switch of (e)make, so you dont 
have to manually
enter/exit the dir.

-- 
Thomas Sachau

Gentoo Linux Developer



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-01 Thread Nirbheek Chauhan
On Fri, Oct 1, 2010 at 6:37 PM, Peter Volkov p...@gentoo.org wrote:
 В Пнд, 27/09/2010 в 11:37 +, Dirkjan Ochtman (djc) пишет:
 src_compile() {
       use static  sed -i -e '/^LIBS/s/LIBS = /LIBS = -static /' Makefile

       emake || die make failed

       if ! use minimal ; then
               cd plugin
               for i in $( ls 2/dev/null ); do

 This is bad construction:
 http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29


A nice way around this is to do the following:

ls -1 | while read i; do

`read` delimits on newline, so you're safe.

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team



[gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in net-misc/openvpn: ChangeLog openvpn-2.1.3.ebuild

2010-10-01 Thread Ryan Hill
On Fri, 1 Oct 2010 20:47:38 +0530
Nirbheek Chauhan nirbh...@gentoo.org wrote:

 On Fri, Oct 1, 2010 at 6:37 PM, Peter Volkov p...@gentoo.org wrote:
  В Пнд, 27/09/2010 в 11:37 +, Dirkjan Ochtman (djc) пишет:
  src_compile() {
        use static  sed -i -e '/^LIBS/s/LIBS = /LIBS = -static /' Makefile
 
        emake || die make failed
 
        if ! use minimal ; then
                cd plugin
                for i in $( ls 2/dev/null ); do
 
  This is bad construction:
  http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29
 
 
 A nice way around this is to do the following:
 
 ls -1 | while read i; do
 
 `read` delimits on newline, so you're safe.

This strips leading and trailing whitespace.

$ touch  test1
$ touch test2 
$ touch test 3
$ touch  test 4 

$ ls -1 | while read i; do echo ###${i}###; done
###test2###
###test 3###
###test1###
###test 4###

instead use:

$ ls -1 | while IFS= read i; do echo ###${i}###; done
###test2 ###
###test 3###
### test1###
### test 4 ###

or recursively:

$ find . -type f -print0 \
  | while IFS= read -d $'\0' i; do echo ###${i}###; done
###./ test1###
###./ test 4 ###
###./test 3###
###./test2 ###

or just make things simple on yourself :)

$ for i in *; do echo ###${i}###; done
### test1###
###test2 ###
###test 3###
### test 4 ###


-- 
fonts, gcc-porting, we hold our breath, we spin around the world
toolchain, wxwidgetsyou and me cling to the outside of the earth
@ gentoo.orgEFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662


signature.asc
Description: PGP signature