Gentoo Archives: gentoo-dev

From: "Marijn Schouten (hkBst)" <hkBst@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] More general interface to use flags
Date: Fri, 02 Nov 2007 14:28:35
Message-Id: 472B33D7.7070906@gentoo.org
In Reply to: Re: [gentoo-dev] More general interface to use flags by Roy Marples
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Roy Marples wrote:
5 > On Fri, 2007-11-02 at 14:44 +0100, Marijn Schouten (hkBst) wrote:
6 >> [[ ${flag} = !* ]] && { success=1 ; flag=${flag:1} }
7 >
8 > Could be written as
9 > [ "${flag#!}" != "${flag}" ] && { success=1; flag=${flag#!}; }
10 >
11 >> string=$( (( ${success} == 0 )) && echo ${string_success} || echo
12 >> ${string_failure} )
13 >> [[ -n ${string} ]] && echo ${string}
14 >
15 > if [ "${success}" = "0" ]; then
16 > string=${string_success}
17 > else
18 > string=${string_failure}
19 > fi
20 > [ -n "${string}" ] && echo "${string}"
21
22 Actually I'd prefer to introduce
23
24 ifz() {
25 [[ $1 = 0 ]] && echo $2 || echo $3
26 }
27
28 and reimplement as follows
29
30 string=$(ifz ${success} "${string_success}" "${string_failure}")
31
32 but I don't want to push my luck,
33
34 Marijn
35
36 - --
37 Marijn Schouten (hkBst), Gentoo Lisp project
38 <http://www.gentoo.org/proj/en/lisp/>, #gentoo-lisp on FreeNode
39 -----BEGIN PGP SIGNATURE-----
40 Version: GnuPG v2.0.7 (GNU/Linux)
41 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
42
43 iD8DBQFHKzPXp/VmCx0OL2wRAhvNAKCB5yPezkffi/QXx6aDEXsgB662kwCfb3DV
44 SDZ66FZzdoSF3uftGd+ZBik=
45 =ylxW
46 -----END PGP SIGNATURE-----
47 --
48 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] More general interface to use flags Roy Marples <uberlord@g.o>