FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 04-13-2012, 10:49 AM
Florian Pritz
 
Default validate shell scripts with $(BASH_SHELL) on build

On 13.04.2012 05:30, Allan McRae wrote:
> On 13/04/12 00:54, Dave Reisner wrote:
>> Pass $(OURSCRIPTS) through the bash parser in read only mode to validate
>> syntax. Note that this doesn't actually catch all errors, but it might
>> be useful for developers working on these scripts.
>>
>> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
>> ---
>> contrib/Makefile.am | 1 +
>> scripts/Makefile.am | 1 +
>> 2 files changed, 2 insertions(+)
>>
>> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
>> index eca39e7..2953912 100644
>> --- a/contrib/Makefile.am
>> +++ b/contrib/Makefile.am
>> @@ -55,6 +55,7 @@ $(OURSCRIPTS): Makefile
>> $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
>> $(AM_V_at)chmod +x,a-w $@.tmp
>> $(AM_V_at)mv $@.tmp $@
>> + @$(BASH_SHELL) -O extglob -n $@
>
> I'm missing why we need extglob here?

bacman and paccache use extglobs

--
Florian Pritz
 
Old 04-13-2012, 10:57 AM
Allan McRae
 
Default validate shell scripts with $(BASH_SHELL) on build

On 13/04/12 20:49, Florian Pritz wrote:
> On 13.04.2012 05:30, Allan McRae wrote:
>> On 13/04/12 00:54, Dave Reisner wrote:
>>> Pass $(OURSCRIPTS) through the bash parser in read only mode to validate
>>> syntax. Note that this doesn't actually catch all errors, but it might
>>> be useful for developers working on these scripts.
>>>
>>> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
>>> ---
>>> contrib/Makefile.am | 1 +
>>> scripts/Makefile.am | 1 +
>>> 2 files changed, 2 insertions(+)
>>>
>>> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
>>> index eca39e7..2953912 100644
>>> --- a/contrib/Makefile.am
>>> +++ b/contrib/Makefile.am
>>> @@ -55,6 +55,7 @@ $(OURSCRIPTS): Makefile
>>> $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
>>> $(AM_V_at)chmod +x,a-w $@.tmp
>>> $(AM_V_at)mv $@.tmp $@
>>> + @$(BASH_SHELL) -O extglob -n $@
>>
>> I'm missing why we need extglob here?
>
> bacman and paccache use extglobs
>

Yes... and every time someone calls one of those scripts they have to
manually set the extglob? No... because that would be stupid.
 
Old 04-13-2012, 12:57 PM
Dave Reisner
 
Default validate shell scripts with $(BASH_SHELL) on build

On Fri, Apr 13, 2012 at 6:57 AM, Allan McRae <allan@archlinux.org> wrote:

> On 13/04/12 20:49, Florian Pritz wrote:
> > On 13.04.2012 05:30, Allan McRae wrote:
> >> On 13/04/12 00:54, Dave Reisner wrote:
> >>> Pass $(OURSCRIPTS) through the bash parser in read only mode to
> validate
> >>> syntax. Note that this doesn't actually catch all errors, but it might
> >>> be useful for developers working on these scripts.
> >>>
> >>> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
> >>> ---
> >>> contrib/Makefile.am | 1 +
> >>> scripts/Makefile.am | 1 +
> >>> 2 files changed, 2 insertions(+)
> >>>
> >>> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
> >>> index eca39e7..2953912 100644
> >>> --- a/contrib/Makefile.am
> >>> +++ b/contrib/Makefile.am
> >>> @@ -55,6 +55,7 @@ $(OURSCRIPTS): Makefile
> >>> $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
> >>> $(AM_V_at)chmod +x,a-w $@.tmp
> >>> $(AM_V_at)mv $@.tmp $@
> >>> + @$(BASH_SHELL) -O extglob -n $@
> >>
> >> I'm missing why we need extglob here?
> >
> > bacman and paccache use extglobs
> >
>
> Yes... and every time someone calls one of those scripts they have to
> manually set the extglob? No... because that would be stupid.
>

It would be stupid, but this is bash... So let's ignore rational thought
for a minute.

$ bash -n ./scripts/repo-add
./scripts/repo-add: line 261: syntax error near unexpected token `('
./scripts/repo-add: line 261: ` *.@(db|files).tar.gz) TAR_OPT="z"
;;'

no-exec mode really does mean no-exec, including shopts that might change
the behavior of the parser.
 
Old 04-13-2012, 01:10 PM
Allan McRae
 
Default validate shell scripts with $(BASH_SHELL) on build

On 13/04/12 22:57, Dave Reisner wrote:
> On Fri, Apr 13, 2012 at 6:57 AM, Allan McRae <allan@archlinux.org> wrote:
>
>> On 13/04/12 20:49, Florian Pritz wrote:
>>> On 13.04.2012 05:30, Allan McRae wrote:
>>>> On 13/04/12 00:54, Dave Reisner wrote:
>>>>> Pass $(OURSCRIPTS) through the bash parser in read only mode to
>> validate
>>>>> syntax. Note that this doesn't actually catch all errors, but it might
>>>>> be useful for developers working on these scripts.
>>>>>
>>>>> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
>>>>> ---
>>>>> contrib/Makefile.am | 1 +
>>>>> scripts/Makefile.am | 1 +
>>>>> 2 files changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
>>>>> index eca39e7..2953912 100644
>>>>> --- a/contrib/Makefile.am
>>>>> +++ b/contrib/Makefile.am
>>>>> @@ -55,6 +55,7 @@ $(OURSCRIPTS): Makefile
>>>>> $(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
>>>>> $(AM_V_at)chmod +x,a-w $@.tmp
>>>>> $(AM_V_at)mv $@.tmp $@
>>>>> + @$(BASH_SHELL) -O extglob -n $@
>>>>
>>>> I'm missing why we need extglob here?
>>>
>>> bacman and paccache use extglobs
>>>
>>
>> Yes... and every time someone calls one of those scripts they have to
>> manually set the extglob? No... because that would be stupid.
>>
>
> It would be stupid, but this is bash... So let's ignore rational thought
> for a minute.
>
> $ bash -n ./scripts/repo-add
> ./scripts/repo-add: line 261: syntax error near unexpected token `('
> ./scripts/repo-add: line 261: ` *.@(db|files).tar.gz) TAR_OPT="z"
> ;;'
>
> no-exec mode really does mean no-exec, including shopts that might change
> the behavior of the parser.

Ok then. Bash does something I don't expect yet again!

One thing that will do is cause any script where extglob is needed but
not enabled to "pass". But I think fixing that would be a pain and also
really is not necessary so ignore...
 

Thread Tools




All times are GMT. The time now is 05:20 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org