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 03-11-2009, 09:47 PM
Xavier
 
Default bash scripts errexit and nounset options

I found this page while implementing the locking system for repo-add,
I stole some code from it :
http://www.davidpashley.com/articles/writing-robust-shell-scripts.html

It recommends using set -u and set -e, these both seem like a good idea to me.
Should we try to be consistent using these options in all the bash
scripts in pacman repo?
Several already use set -e, but not all of them. And none seem to use set -u.

While I find these two options useful, I wonder if it isn't a bad idea
to introduce them now, as it could cause more harm than good.
I guess that ideally, they would have been set from the beginning.
Adding them now could add some non obvious problems to code that
worked fine.

Anyway, if we agree these flags are indeed useful, they could at least
be considered when adding new scripts.
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 
Old 03-11-2009, 10:06 PM
Allan McRae
 
Default bash scripts errexit and nounset options

Xavier wrote:

I found this page while implementing the locking system for repo-add,
I stole some code from it :
http://www.davidpashley.com/articles/writing-robust-shell-scripts.html

It recommends using set -u and set -e, these both seem like a good idea to me.
Should we try to be consistent using these options in all the bash
scripts in pacman repo?
Several already use set -e, but not all of them. And none seem to use set -u.

While I find these two options useful, I wonder if it isn't a bad idea
to introduce them now, as it could cause more harm than good.
I guess that ideally, they would have been set from the beginning.
Adding them now could add some non obvious problems to code that
worked fine.

Anyway, if we agree these flags are indeed useful, they could at least
be considered when adding new scripts.


How does set -u work when you test if a variable exists? e.g. in
makepkg we test if "$install" is non-null.


Anyway, I think these are good to have as they help us discover errors
in our assumptions. I would be up for adding them to all scripts once
we get the next release out the door.


Allan


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 
Old 03-11-2009, 10:12 PM
Xavier
 
Default bash scripts errexit and nounset options

On Thu, Mar 12, 2009 at 12:06 AM, Allan McRae <allan@archlinux.org> wrote:
>
> How does set -u work when you test if a variable exists? *e.g. in makepkg we
> test if "$install" is non-null.
>

It can be defined and null. That just means we have to declare all
variables we use. So this change would certainly require additional
declarations. I guess more safety comes at a price
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 
Old 03-11-2009, 10:26 PM
Allan McRae
 
Default bash scripts errexit and nounset options

Xavier wrote:

On Thu, Mar 12, 2009 at 12:06 AM, Allan McRae <allan@archlinux.org> wrote:


How does set -u work when you test if a variable exists? e.g. in makepkg we
test if "$install" is non-null.




It can be defined and null. That just means we have to declare all
variables we use. So this change would certainly require additional
declarations. I guess more safety comes at a price


The more I look into including these flags, the more I like the idea.
If you are not going to look into this in the near future, could you
file a bug report so it is not forgotten?


Cheers,
Allan



_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 10:11 AM.

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