[pacman-dev,1/4] util/pkgbuild: guard against unset variable

Message ID 20170225172118.5780-2-andrew.gregory.8@gmail.com
State New
Headers show
Series
  • makepkg test suite
Related show

Commit Message

Andrew Gregory Feb. 25, 2017, 5:21 p.m. UTC
Allows use under 'set -u'.
---
 scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Allan McRae March 2, 2017, 4:37 a.m. UTC | #1
On 26/02/17 03:21, Andrew Gregory wrote:
> Allows use under 'set -u'.
> ---
>  scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
> index 2a4bd3af..08b35f53 100644
> --- a/scripts/libmakepkg/util/pkgbuild.sh.in
> +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
> @@ -18,7 +18,7 @@
>  #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  #
>  
> -[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
> +[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
>  LIBMAKEPKG_UTIL_PKGBUILD_SH=1
>  
>

Is this going to need done for every file that you test?  I'd prefer one
big patch if so.

A
Andrew Gregory March 2, 2017, 4:46 a.m. UTC | #2
On 03/02/17 at 02:37pm, Allan McRae wrote:
> On 26/02/17 03:21, Andrew Gregory wrote:
> > Allows use under 'set -u'.
> > ---
> >  scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
> > index 2a4bd3af..08b35f53 100644
> > --- a/scripts/libmakepkg/util/pkgbuild.sh.in
> > +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
> > @@ -18,7 +18,7 @@
> >  #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> >  #
> >  
> > -[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
> > +[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
> >  LIBMAKEPKG_UTIL_PKGBUILD_SH=1
> >  
> >
> 
> Is this going to need done for every file that you test?  I'd prefer one
> big patch if so.
> 
> A

If we want to run the tests with 'set -u', this, or something similar
will have to be done for all libmakepkg files.  I actually think
I like `[[ -v LIBMAKEPKG_UTIL_PKGBUILD_SH ]]` better though.

apg
Allan McRae March 2, 2017, 4:59 a.m. UTC | #3
On 02/03/17 14:46, Andrew Gregory wrote:
> On 03/02/17 at 02:37pm, Allan McRae wrote:
>> On 26/02/17 03:21, Andrew Gregory wrote:
>>> Allows use under 'set -u'.
>>> ---
>>>  scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
>>> index 2a4bd3af..08b35f53 100644
>>> --- a/scripts/libmakepkg/util/pkgbuild.sh.in
>>> +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
>>> @@ -18,7 +18,7 @@
>>>  #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>>  #
>>>  
>>> -[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
>>> +[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
>>>  LIBMAKEPKG_UTIL_PKGBUILD_SH=1
>>>  
>>>
>>
>> Is this going to need done for every file that you test?  I'd prefer one
>> big patch if so.
>>
>> A
> 
> If we want to run the tests with 'set -u', this, or something similar
> will have to be done for all libmakepkg files.  I actually think
> I like `[[ -v LIBMAKEPKG_UTIL_PKGBUILD_SH ]]` better though.
> 

How long has bash 4.2 been around?   Our minimum is currently 4.1.
Andrew Gregory March 2, 2017, 5:11 a.m. UTC | #4
On 03/02/17 at 02:59pm, Allan McRae wrote:
> On 02/03/17 14:46, Andrew Gregory wrote:
> > On 03/02/17 at 02:37pm, Allan McRae wrote:
> >> On 26/02/17 03:21, Andrew Gregory wrote:
> >>> Allows use under 'set -u'.
> >>> ---
> >>>  scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
> >>> index 2a4bd3af..08b35f53 100644
> >>> --- a/scripts/libmakepkg/util/pkgbuild.sh.in
> >>> +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
> >>> @@ -18,7 +18,7 @@
> >>>  #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
> >>>  #
> >>>  
> >>> -[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
> >>> +[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
> >>>  LIBMAKEPKG_UTIL_PKGBUILD_SH=1
> >>>  
> >>>
> >>
> >> Is this going to need done for every file that you test?  I'd prefer one
> >> big patch if so.
> >>
> >> A
> > 
> > If we want to run the tests with 'set -u', this, or something similar
> > will have to be done for all libmakepkg files.  I actually think
> > I like `[[ -v LIBMAKEPKG_UTIL_PKGBUILD_SH ]]` better though.
> > 
> 
> How long has bash 4.2 been around?   Our minimum is currently 4.1.

4.2 appears to have been tagged at the end of 2011.
Eli Schwartz Sept. 20, 2018, 3:35 a.m. UTC | #5
On 3/2/17 00:11 AM, Andrew Gregory wrote:
> On 03/02/17 at 02:59pm, Allan McRae wrote:
>> On 02/03/17 14:46, Andrew Gregory wrote:
>> > On 03/02/17 at 02:37pm, Allan McRae wrote:
>> >> On 26/02/17 03:21, Andrew Gregory wrote:
>> >>> Allows use under 'set -u'.
>> >>> ---
>> >>>  scripts/libmakepkg/util/pkgbuild.sh.in | 2 +-
>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
>> >>> index 2a4bd3af..08b35f53 100644
>> >>> --- a/scripts/libmakepkg/util/pkgbuild.sh.in
>> >>> +++ b/scripts/libmakepkg/util/pkgbuild.sh.in
>> >>> @@ -18,7 +18,7 @@
>> >>>  #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> >>>  #
>> >>>  
>> >>> -[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
>> >>> +[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
>> >>>  LIBMAKEPKG_UTIL_PKGBUILD_SH=1
>> >>>  
>> >>>
>> >>
>> >> Is this going to need done for every file that you test?  I'd prefer one
>> >> big patch if so.
>> >>
>> >> A
>> > 
>> > If we want to run the tests with 'set -u', this, or something similar
>> > will have to be done for all libmakepkg files.  I actually think
>> > I like `[[ -v LIBMAKEPKG_UTIL_PKGBUILD_SH ]]` better though.
>> > 
>> 
>> How long has bash 4.2 been around?   Our minimum is currently 4.1.
>
> 4.2 appears to have been tagged at the end of 2011.

We now require 4.4 anyway...

Patch

diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 2a4bd3af..08b35f53 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -18,7 +18,7 @@ 
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
+[[ -n "${LIBMAKEPKG_UTIL_PKGBUILD_SH:-}" ]] && return
 LIBMAKEPKG_UTIL_PKGBUILD_SH=1