David Pashley: Writing Robust Shell Scripts Article
I've just finished writing an
article on tips for making your shell scripts more robust. Comments
welcome.
open( FILENAME [,MODE [,PERMS]] )so you write:
open( FILENAME, IOLAYERS )
my $rules = new IO::File('debian/rules','w', 0755);
and wonder why it hasn't changed the permissions from 0666. Stracing
confirms it is opened 0666:
open("./debian/rules", O_WRONLY O_CREAT O_TRUNC O_LARGEFILE, 0666) = 4
A bit further reading of the documentation you discover:
If IO::File::open receives a Perl mode string (">", "+<", etc.) or an ANSI C fopen() mode string ("w", "r+", etc.), it uses the basic Perl open operator (but protects any special characters). If IO::File::open is given a numeric mode, it passes that mode and the optional permissions value to the Perl sysopen operator. The permissions default to 0666. If IO::File::open is given a mode that includes the : character, it passes all the three arguments to the three-argument open operator. For convenience, IO::File exports the O_XXX constants from the Fcntl module, if this module is available.and the correct way to write this is
my $rules = new IO::File('debian/rules',O_WRONLY O_CREAT O_TRUNC O_LARGEFILE, 0755)
Thank you very much perl for ignoring the permission parameter when
you feel like it.
Update: Steinar,
yes sorry, I did have 0755 rather than "0755"
originally, but changed it just to check that didn't make a difference
and copied the wrong version. I've changed the post to have the right
thing.
% strace -eopen perl -MIO::File \
-e 'my $rules = new IO::File("foo","w", 0755);' 2>&1 grep foo
open("./foo", O_WRONLY O_CREAT O_TRUNC O_LARGEFILE, 0666) = 3
% strace -eopen perl -MIO::File \
-e 'my $rules = new IO::File("foo","w", "0755");' 2>&1 grep foo
open("./foo", O_WRONLY O_CREAT O_TRUNC O_LARGEFILE, 0666) = 3
Incidentally, 0755 and "0755" are different:
perl -e 'printf("%d %d\n", 0755, "0755");'
493 755
22:07 <@Laura-> no, there is anotherNot only does my girlfriend use irc, she quotes Star Wars. *squee*
I don't think a card says "I love you" so much as "Society expects me to buy you a piece of paper, so I felt obligated to get you this."Discuss.
This talk offers a "Debian Themed" quick tour through the academic, legal, and business worlds. It overs insight into what everyone outside of Debian is saying about, doing with, and learning from the Debian project. In doing so, it hopes to give Debian participants some insight into fields and areas that they are largely unfamiliar with (e.g., management, sociology, anthropology, economics, computer supported collaborative work, etc.). It illuminates what others -- especially academics -- find useful or inspiring about the project and to facilitate self-reflection and self-improvement within Debian. It reflects on the impact that Debian has had in the world beyond the Debian project and, in particular, in those areas that many Debian developers may not be familiar with.The good news is that the proposal was accepted. The bad news is that this means I actually have to finish doing the research to make the talk happen. To make the talk excellent, I wanted to solicit examples from you, great Debian community. I've already got my own list but I'd like to hear what you think I should talk about? What I'm not looking for is examples of people or organizations that use Debian. This talk is not about people who use the OS or the people who build it. This is about people who have learned from Debian as a community. Primarily, I'm looking for academic publications on Debian. However, anyone who has learned and designed a system or community based on such a paper or from observation would be good as well. People who use or have learned from our voting structure might be a good example as would communities with a Debian-derived social contract. Software engineering research is fair game. Be creative but remember that I've got a limited time on the podium and may be forced into the unpleasant position of being ruthlessly selective. Please add examples to this wiki page or just email mako@debian.org. That's if for now and I'll see you in... Umm... Oaxtepec.
$self-> catalina_base = $ENV 'CATALINA_BASE' ;
if (!defined $self-> catalina_base )
$self-> catalina_base = $self->getTomcatHome() ;
if (!defined $self-> catalina_base )
CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3);
or
$self-> catalina_base = $ENV 'CATALINA_BASE' $self->getTomcatHome()
CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3);
Update: or
$self-> catalina_base = (
$ENV 'CATALINA_BASE'
or $self->getTomcatHome()
or CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3)
);
Q. Why do you only display legislation back to 1988? A. The website was launched in 1996. Initially, legislation was only available from that year. In 2000 we took the decision to include older legislation for which we had electronic files. These files only dated back to 1988. Prior to this, legislation is only available in its original print format.I don't think it's acceptable to say "Oh it's a bit of work to make them available." If Project Gutenberg can make 17,000 out of copyright works available, I fail to see why the government, who have resources at their disposal, can't make the text of approximately 3000 acts from the last 100 years available. This makes several key acts which govern us today unavailable to the UK public, including the Telecommunications Act 1984, Sale of Goods Act 1979, Supply of Goods and Services Act 1982 and Unfair Contract Terms Act 1977. On a similar note, they have only just started making PDF files avilable for download (since October 2005). They don't appear to be planning on making existing documents available in PDF. Again, I don't think it would be too hard to make all their content availble in alternative formats.
I don't know if I'm more insulted about only coming third or by the
fact that I don't get a prize. Wish I'd slept with his girlfriend now
(or at least her sister).
You can run Jono, but you can't hide.
Next.