* [gentoo-dev] [RFC] base.eclass
@ 2010-01-02 15:52 Tomáš Chvátal
2010-01-02 16:12 ` Ben de Groot
2010-01-03 0:56 ` [gentoo-dev] " Mark Bateman
0 siblings, 2 replies; 8+ messages in thread
From: Tomáš Chvátal @ 2010-01-02 15:52 UTC (permalink / raw
To: gentoo-dev, qa, loki_val
[-- Attachment #1.1: Type: text/plain, Size: 860 bytes --]
Hola,
I have incorporated all fixes to base.eclass that has been itching me
for a while (closes both open bugs).
Whats new:
* base_src_install docs
this thingie install docs and html_docs from bash array defined in
global scope (or anywhere else indeed :P)
* all bash variable arrays including the PATCHES one have support for
folders
* using same codestyle everywhere...
* using pushd/popd instead of cd
Diff and full eclass attached.
Living link:
http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=blob;f=eclass/base.eclass
Also i would recommend we in QA take over maintainership for this eclass
if Peter wont mind or comaintain with him if he wants not to proxy all
changes through us?
Any more suggestions for this eclass or bugs you find reply please to
-dev thread so we keep it nicely folded for everyone
Tom
[-- Attachment #1.2: base.eclass --]
[-- Type: text/plain, Size: 6251 bytes --]
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.38 2009/05/17 09:25:55 loki_val Exp $
# @ECLASS: base.eclass
# @MAINTAINER:
# Peter Alfredsen <loki_val@gentoo.org>
#
# Original author Dan Armak <danarmak@gentoo.org>
# @BLURB: The base eclass defines some default functions and variables.
# @DESCRIPTION:
# The base eclass defines some default functions and variables. Nearly
# everything else inherits from here.
inherit eutils
case "${EAPI:-0}" in
2|3)
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
;;
*)
EXPORT_FUNCTIONS src_unpack src_compile src_install
;;
esac
# @ECLASS-VARIABLE: DOCS
# @USAGE: DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
# @DESCRIPTION:
# Array containing documents passed to dodoc command.
# @ECLASS-VARIABLE: HTML_DOCS
# @DESCRIPTION: HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
# Array containing documents passed to dohtml command.
# @ECLASS-VARIABLE: PATCHES
# @USAGE: PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
# @DESCRIPTION:
# PATCHES array variable containing all various patches to be applied.
# This variable is expected to be defined in global scope of ebuild.
# Make sure to specify the full path. This variable is utilised in
# src_unpack/src_prepare phase based on EAPI.
# NOTE: if using patches folders with special file suffixes you have to
# define one additional variable EPATCH_SUFFIX="something"
# @FUNCTION: base_src_unpack
# @USAGE: [ unpack ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base src_unpack function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "unpack" if EAPI=2.
base_src_unpack() {
debug-print-function $FUNCNAME "$@"
if [ -z "$1" ]; then
case "${EAPI:-0}" in
2)
base_src_util unpack
;;
*)
base_src_util all
;;
esac
else
base_src_util $@
fi
}
# @FUNCTION: base_src_prepare
# @DESCRIPTION:
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_util autopatch".
base_src_prepare() {
debug-print-function $FUNCNAME "$@"
base_src_util autopatch
}
# @FUNCTION: base_src_util
# @USAGE: [ unpack ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base_src_util function is the grunt function for base src_unpack
# and base src_prepare.
base_src_util() {
debug-print-function $FUNCNAME "$@"
local x oldval
while [ "$1" ]; do
case $1 in
unpack)
debug-print-section unpack
pushd "${WORKDIR}" > /dev/null
[ ! -z "$A" ] && unpack ${A}
popd > /dev/null
;;
autopatch)
debug-print-section autopatch
debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES"
pushd "${S}" > /dev/null
if [[ ${#PATCHES[@]} -gt 1 ]] ; then
for x in "${PATCHES[@]}"; do
debug-print "$FUNCNAME: autopatch: applying patch from ${x}"
[[ -f "${x}" ]] && epatch "${x}"
if [[ -d "${x}" ]]; then
# Use standardized names and locations with bulk patching
# Patch directory is ${WORKDIR}/patch
# See epatch() in eutils.eclass for more documentation
EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
# in order to preserve normal EPATCH_SOURCE value that can
# be used other way than with base eclass store in local
# variable and restore later
oldval=${EPATCH_SOURCE}
EPATCH_SOURCE=${x}
epatch
EPATCH_SOURCE=${oldval}
fi
done
else
for x in ${PATCHES}; do
debug-print "$FUNCNAME: autopatch: patching from ${x}"
epatch "${x}"
done
fi
popd > n/dev/null
;;
all)
debug-print-section all
base_src_util unpack autopatch
;;
esac
shift
done
}
# @FUNCTION: base_src_configure
# @DESCRIPTION:
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_work configure".
base_src_configure() {
debug-print-function $FUNCNAME "$@"
base_src_work configure
}
# @FUNCTION: base_src_compile
# @USAGE: [ configure ] [ make ] [ all ]
# @DESCRIPTION:
# The base src_compile function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "make" if EAPI=2.
base_src_compile() {
debug-print-function $FUNCNAME "$@"
if [ -z "$1" ]; then
case "${EAPI:-0}" in
2)
base_src_work make
;;
*)
base_src_work all
;;
esac
else
base_src_work $@
fi
}
# @FUNCTION: base_src_work
# @USAGE: [ configure ] [ make ] [ all ]
# @DESCRIPTION:
# The base_src_work function is the grunt function for base src_configure
# and base src_compile.
base_src_work() {
debug-print-function $FUNCNAME "$@"
pushd "${S}" > /dev/null
while [ "$1" ]; do
case $1 in
configure)
debug-print-section configure
if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
econf || die "died running econf, $FUNCNAME:configure"
fi
;;
make)
debug-print-section make
if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
emake || die "died running emake, $FUNCNAME:make"
fi
;;
all)
debug-print-section all
base_src_work configure make
;;
esac
shift
done
popd > /dev/null
}
# @FUNCTION: base_src_install
# @USAGE: [ make ] [ docs ] [ all ]
# @DESCRIPTION:
# The base src_install function, which is exported. If no argument is given,
# "all" is assumed.
base_src_install() {
debug-print-function $FUNCNAME "$@"
local x
[ -z "$1" ] && base_src_install all
pushd "${S}" > /dev/null
while [ "$1" ]; do
case $1 in
make)
debug-print-section make
emake DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make"
;;
docs)
debug-print-section docs
if [[ ${#DOCS[@]} -gt 1 ]] ; then
for x in "${DOCS[@]}"; do
debug-print "$FUNCNAME: docs: creating document from ${x}"
dodoc -r "${x}" || die "dodoc failed"
done
fi
if [[ ${#HTML_DOCS[@]} -gt 1 ]] ; then
for x in "${HTML_DOCS[@]}"; do
debug-print "$FUNCNAME: docs: creating html document from ${x}"
dohtml -r "${x}" || die "dohtml failed"
done
fi
;;
all)
debug-print-section all
base_src_install make docs
;;
esac
shift
done
popd > /dev/null
}
[-- Attachment #1.3: base.eclass.diff --]
[-- Type: text/plain, Size: 7766 bytes --]
--- /home/scarab/gentoo/gentoo-x86/eclass/base.eclass 2009-05-25 17:05:03.000000000 +0200
+++ /usr/local/portage/kde/eclass/base.eclass 2010-01-02 16:40:59.000000000 +0100
@@ -11,15 +11,11 @@
# @DESCRIPTION:
# The base eclass defines some default functions and variables. Nearly
# everything else inherits from here.
-#
-# NOTE: You must define EAPI before inheriting from base, or the wrong functions
-# may be exported.
-
inherit eutils
case "${EAPI:-0}" in
- 2)
+ 2|3)
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
;;
*)
@@ -27,18 +23,35 @@
;;
esac
-DESCRIPTION="Based on the $ECLASS eclass"
+# @ECLASS-VARIABLE: DOCS
+# @USAGE: DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" )
+# @DESCRIPTION:
+# Array containing documents passed to dodoc command.
+
+# @ECLASS-VARIABLE: HTML_DOCS
+# @DESCRIPTION: HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" )
+# Array containing documents passed to dohtml command.
+
+# @ECLASS-VARIABLE: PATCHES
+# @USAGE: PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" )
+# @DESCRIPTION:
+# PATCHES array variable containing all various patches to be applied.
+# This variable is expected to be defined in global scope of ebuild.
+# Make sure to specify the full path. This variable is utilised in
+# src_unpack/src_prepare phase based on EAPI.
+# NOTE: if using patches folders with special file suffixes you have to
+# define one additional variable EPATCH_SUFFIX="something"
+
# @FUNCTION: base_src_unpack
-# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
+# @USAGE: [ unpack ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base src_unpack function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "unpack" if EAPI=2.
base_src_unpack() {
-
debug-print-function $FUNCNAME "$@"
- if [ -z "$1" ] ; then
+ if [ -z "$1" ]; then
case "${EAPI:-0}" in
2)
base_src_util unpack
@@ -57,63 +70,72 @@
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_util autopatch".
base_src_prepare() {
-
debug-print-function $FUNCNAME "$@"
base_src_util autopatch
}
# @FUNCTION: base_src_util
-# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
+# @USAGE: [ unpack ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base_src_util function is the grunt function for base src_unpack
# and base src_prepare.
base_src_util() {
- local x
-
debug-print-function $FUNCNAME "$@"
- cd "${WORKDIR}"
+ local x oldval
while [ "$1" ]; do
+ case $1 in
+ unpack)
+ debug-print-section unpack
+
+ pushd "${WORKDIR}" > /dev/null
+ [ ! -z "$A" ] && unpack ${A}
+ popd > /dev/null
+ ;;
+ autopatch)
+ debug-print-section autopatch
+ debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES"
+
+ pushd "${S}" > /dev/null
+
+ if [[ ${#PATCHES[@]} -gt 1 ]] ; then
+ for x in "${PATCHES[@]}"; do
+ debug-print "$FUNCNAME: autopatch: applying patch from ${x}"
+ [[ -f "${x}" ]] && epatch "${x}"
+ if [[ -d "${x}" ]]; then
+ # Use standardized names and locations with bulk patching
+ # Patch directory is ${WORKDIR}/patch
+ # See epatch() in eutils.eclass for more documentation
+ EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch}
+
+ # in order to preserve normal EPATCH_SOURCE value that can
+ # be used other way than with base eclass store in local
+ # variable and restore later
+ oldval=${EPATCH_SOURCE}
+ EPATCH_SOURCE=${x}
+ epatch
+ EPATCH_SOURCE=${oldval}
+ fi
+ done
+ else
+ for x in ${PATCHES}; do
+ debug-print "$FUNCNAME: autopatch: patching from ${x}"
+ epatch "${x}"
+ done
+ fi
- case $1 in
- unpack)
- debug-print-section unpack
- if [ ! -z "$A" ] ; then
- unpack ${A}
- fi
- ;;
- patch)
- debug-print-section patch
- cd "${S}"
- epatch "${FILESDIR}/${P}-gentoo.diff"
- ;;
- autopatch)
- debug-print-section autopatch
- debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES, PATCHES1=$PATCHES1"
- cd "${S}"
- if [[ ${#PATCHES[@]} -gt 1 ]] ; then
- for x in "${PATCHES[@]}"; do
- debug-print "$FUNCNAME: autopatch: patching from ${x}"
- epatch "${x}"
- done
- else
- for x in ${PATCHES} ${PATCHES1}; do
- debug-print "$FUNCNAME: autopatch: patching from ${x}"
- epatch "${x}"
- done
- fi
- ;;
- all)
- debug-print-section all
- base_src_util unpack autopatch
- ;;
- esac
+ popd > n/dev/null
+ ;;
+ all)
+ debug-print-section all
+ base_src_util unpack autopatch
+ ;;
+ esac
- shift
+ shift
done
-
}
# @FUNCTION: base_src_configure
@@ -121,7 +143,6 @@
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_work configure".
base_src_configure() {
-
debug-print-function $FUNCNAME "$@"
base_src_work configure
@@ -133,11 +154,9 @@
# The base src_compile function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "make" if EAPI=2.
base_src_compile() {
-
debug-print-function $FUNCNAME "$@"
- if [ -z "$1" ]
- then
+ if [ -z "$1" ]; then
case "${EAPI:-0}" in
2)
base_src_work make
@@ -157,65 +176,78 @@
# The base_src_work function is the grunt function for base src_configure
# and base src_compile.
base_src_work() {
-
debug-print-function $FUNCNAME "$@"
- cd "${S}"
+ pushd "${S}" > /dev/null
while [ "$1" ]; do
+ case $1 in
+ configure)
+ debug-print-section configure
+ if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
+ econf || die "died running econf, $FUNCNAME:configure"
+ fi
+ ;;
+ make)
+ debug-print-section make
+ if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
+ emake || die "died running emake, $FUNCNAME:make"
+ fi
+ ;;
+ all)
+ debug-print-section all
+ base_src_work configure make
+ ;;
+ esac
- case $1 in
- configure)
- debug-print-section configure
- if [[ -x ${ECONF_SOURCE:-.}/configure ]]
- then
- econf || die "died running econf, $FUNCNAME:configure"
- fi
- ;;
- make)
- debug-print-section make
- if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]
- then
- emake || die "died running emake, $FUNCNAME:make"
- fi
- ;;
- all)
- debug-print-section all
- base_src_work configure make
- ;;
- esac
-
- shift
+ shift
done
+ popd > /dev/null
}
# @FUNCTION: base_src_install
-# @USAGE: [ make ] [ all ]
+# @USAGE: [ make ] [ docs ] [ all ]
# @DESCRIPTION:
# The base src_install function, which is exported. If no argument is given,
# "all" is assumed.
base_src_install() {
-
debug-print-function $FUNCNAME "$@"
+
+ local x
[ -z "$1" ] && base_src_install all
- cd "${S}"
+ pushd "${S}" > /dev/null
while [ "$1" ]; do
+ case $1 in
+ make)
+ debug-print-section make
+ emake DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make"
+ ;;
+ docs)
+ debug-print-section docs
+ if [[ ${#DOCS[@]} -gt 1 ]] ; then
+ for x in "${DOCS[@]}"; do
+ debug-print "$FUNCNAME: docs: creating document from ${x}"
+ dodoc -r "${x}" || die "dodoc failed"
+ done
+ fi
+ if [[ ${#HTML_DOCS[@]} -gt 1 ]] ; then
+ for x in "${HTML_DOCS[@]}"; do
+ debug-print "$FUNCNAME: docs: creating html document from ${x}"
+ dohtml -r "${x}" || die "dohtml failed"
+ done
+ fi
+ ;;
+ all)
+ debug-print-section all
+ base_src_install make docs
+ ;;
+ esac
- case $1 in
- make)
- debug-print-section make
- make DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make"
- ;;
- all)
- debug-print-section all
- base_src_install make
- ;;
- esac
-
- shift
+ shift
done
+ popd > /dev/null
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [RFC] base.eclass
2010-01-02 15:52 [gentoo-dev] [RFC] base.eclass Tomáš Chvátal
@ 2010-01-02 16:12 ` Ben de Groot
2010-01-02 16:31 ` Tomáš Chvátal
2010-01-03 0:56 ` [gentoo-dev] " Mark Bateman
1 sibling, 1 reply; 8+ messages in thread
From: Ben de Groot @ 2010-01-02 16:12 UTC (permalink / raw
To: gentoo-dev
2010/1/2 Tomáš Chvátal <scarabeus@gentoo.org>:
> Hola,
> I have incorporated all fixes to base.eclass that has been itching me
> for a while (closes both open bugs).
>
> Whats new:
> * base_src_install docs
> this thingie install docs and html_docs from bash array defined in
> global scope (or anywhere else indeed :P)
>
> * all bash variable arrays including the PATCHES one have support for
> folders
>
> * using same codestyle everywhere...
>
> * using pushd/popd instead of cd
>
> Diff and full eclass attached.
I support this.
Also, I would recommend using [[ instead of [ for tests throughout. It
is safer and better coding practice.
( See http://mywiki.wooledge.org/BashGuide/Practices/BashTests )
Cheers,
--
Ben de Groot
Gentoo Linux developer (qt, media, lxde, desktop-misc)
______________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gentoo-dev] Re: [RFC] base.eclass
2010-01-02 15:52 [gentoo-dev] [RFC] base.eclass Tomáš Chvátal
2010-01-02 16:12 ` Ben de Groot
@ 2010-01-03 0:56 ` Mark Bateman
2010-01-03 1:56 ` Tomáš Chvátal
1 sibling, 1 reply; 8+ messages in thread
From: Mark Bateman @ 2010-01-03 0:56 UTC (permalink / raw
To: gentoo-dev
Tomáš Chvátal <scarabeus <at> gentoo.org> writes:
>
> Hola,
> I have incorporated all fixes to base.eclass that has been itching me
> for a while (closes both open bugs).
>
> Whats new:
> * base_src_install docs
> this thingie install docs and html_docs from bash array defined in
> global scope (or anywhere else indeed :P)
>
> * all bash variable arrays including the PATCHES one have support for
> folders
>
> * using same codestyle everywhere...
>
> * using pushd/popd instead of cd
>
> Diff and full eclass attached.
>
> Living link:
> http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=blob;f=eclass/base.eclass
>
There seems to be alot of unquoted variables
65 base_src_util $@
90 case $1 in
95 [[ ! -z "${A}" ]] && unpack ${A}
117 oldval=${EPATCH_SOURCE}
118 EPATCH_SOURCE=${x}
120 EPATCH_SOURCE=${oldval}
Also a typo: an "n" slipped in
130 popd > n/dev/null
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [RFC] base.eclass
2010-01-03 0:56 ` [gentoo-dev] " Mark Bateman
@ 2010-01-03 1:56 ` Tomáš Chvátal
2010-01-03 6:23 ` Harald van Dijk
0 siblings, 1 reply; 8+ messages in thread
From: Tomáš Chvátal @ 2010-01-03 1:56 UTC (permalink / raw
To: gentoo-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dne 3.1.2010 01:56, Mark Bateman napsal(a):
> There seems to be alot of unquoted variables
>
> 65 base_src_util $@
This is not problem
>
> 90 case $1 in
Yarp this is problem and fixed
>
> 95 [[ ! -z "${A}" ]] && unpack ${A}
${A} is not used quoted :]
>
> 117 oldval=${EPATCH_SOURCE}
> 118 EPATCH_SOURCE=${x}
> 120 EPATCH_SOURCE=${oldval}
Variables assignment is not requiring quoting.
>
> Also a typo: an "n" slipped in
> 130 popd > n/dev/null
Great spot, fixed
Thanks for your help with review :]
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAks/+UkACgkQHB6c3gNBRYfBqQCcC3iJXXHsGWLyQg2Ab8+/wH0h
/BgAoKxzfgbhl0MbKh8UUn1hTJyTzo1z
=Fv6C
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [RFC] base.eclass
2010-01-03 1:56 ` Tomáš Chvátal
@ 2010-01-03 6:23 ` Harald van Dijk
2010-01-03 10:28 ` Ulrich Mueller
0 siblings, 1 reply; 8+ messages in thread
From: Harald van Dijk @ 2010-01-03 6:23 UTC (permalink / raw
To: gentoo-dev
On Sun, Jan 03, 2010 at 02:56:01AM +0100, Tomáš Chvátal wrote:
> Dne 3.1.2010 01:56, Mark Bateman napsal(a):
> > There seems to be alot of unquoted variables
> >
> > 65 base_src_util $@
> This is not problem
Only because you can be sure there will be exactly one word in the
result, which will not be split. In general, $@ should be quoted, and it
would be a good idea to either do it here too even though it's not
strictly necessary, or make the intent clearer and just write
base_src_util $1
> > 90 case $1 in
> Yarp this is problem and fixed
That's not a problem. A case expression is another example where quoting
is unnecessary; there won't be any word splitting on $1 anyway.
> > 95 [[ ! -z "${A}" ]] && unpack ${A}
> ${A} is not used quoted :]
Right, that doesn't need quoting, and it would even be okay to drop the
unnecessary quotes in [[.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [RFC] base.eclass
2010-01-03 6:23 ` Harald van Dijk
@ 2010-01-03 10:28 ` Ulrich Mueller
2010-01-03 11:00 ` Harald van Dijk
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Mueller @ 2010-01-03 10:28 UTC (permalink / raw
To: gentoo-dev
>>>>> On Sun, 3 Jan 2010, Harald van Dijk wrote:
>> > 65 base_src_util $@
>> This is not problem
> Only because you can be sure there will be exactly one word in the
> result, which will not be split. In general, $@ should be quoted, and it
> would be a good idea to either do it here too even though it's not
> strictly necessary, or make the intent clearer and just write
> base_src_util $1
I think this would not be correct. Note the while loop over parameters
in base_src_util. So it should be "$@" (with quotes).
>> > 90 case $1 in
>> Yarp this is problem and fixed
> That's not a problem. A case expression is another example where
> quoting is unnecessary; there won't be any word splitting on $1
> anyway.
Right, so you should remove these quotes again.
>> > 95 [[ ! -z "${A}" ]] && unpack ${A}
>> ${A} is not used quoted :]
> Right, that doesn't need quoting, and it would even be okay to drop
> the unnecessary quotes in [[.
s/it would even be okay to/you should/
Only cases where you need quotes inside [[ ]] are:
1. whitespace or special characters that must be quoted,
2. suppress pattern matching for the right hand side of an == or !=
expression.
Ulrich
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] Re: [RFC] base.eclass
2010-01-03 10:28 ` Ulrich Mueller
@ 2010-01-03 11:00 ` Harald van Dijk
0 siblings, 0 replies; 8+ messages in thread
From: Harald van Dijk @ 2010-01-03 11:00 UTC (permalink / raw
To: gentoo-dev
On Sun, Jan 03, 2010 at 11:28:27AM +0100, Ulrich Mueller wrote:
> >>>>> On Sun, 3 Jan 2010, Harald van Dijk wrote:
>
> >> > 65 base_src_util $@
> >> This is not problem
>
> > Only because you can be sure there will be exactly one word in the
> > result, which will not be split. In general, $@ should be quoted, and it
> > would be a good idea to either do it here too even though it's not
> > strictly necessary, or make the intent clearer and just write
>
> > base_src_util $1
>
> I think this would not be correct. Note the while loop over parameters
> in base_src_util.
You're right. I'm so used to src_unpack normally not having any arguments
that I didn't stop to think base_src_unpack could easily be called
explicitly, with as many parameters as you'd like. Checking shows this
is not done in the tree (never more than one parameter, and usually
zero), but that's no reason to drop it. :)
> So it should be "$@" (with quotes).
That'd be better, but my point still stands: the arguments to
base_src_unpack won't ever contain anything that can be expanded, so quoting
isn't strictly necessary, just a good idea.
Not that I'm against the quoting, of course.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-01-03 11:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-02 15:52 [gentoo-dev] [RFC] base.eclass Tomáš Chvátal
2010-01-02 16:12 ` Ben de Groot
2010-01-02 16:31 ` Tomáš Chvátal
2010-01-03 0:56 ` [gentoo-dev] " Mark Bateman
2010-01-03 1:56 ` Tomáš Chvátal
2010-01-03 6:23 ` Harald van Dijk
2010-01-03 10:28 ` Ulrich Mueller
2010-01-03 11:00 ` Harald van Dijk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox