kcrisman wrote: > Dear Dave, > > I think you have a lot of really good ideas about portability. > However, my fear is that there are so many scripts out there, and > people without your knowledge won't have a place to go. > > Would you be willing to write something for the developer guide that > has ALL your recommendations on things to avoid - whether deprecated > options like this, or GNUisms (whatever they are), > that could be put very prominently in the guide? This would probably really > help things > in the long run, especially for those of us who barely can write a > shell script as it is :) > > Thanks, > > - kcrisman
Yes, I'll do that. I wont promise when, as I am a bit busy now. Many of these things can be found in documents on the web, but it would no doubt help to have them in the developer guide, particularly those related to Sage. There are probably 10-20 mistakes in the build scripts in Sage which make up 90% of the portability issues. Some like this && instead of '-a' does not cause any problems in Sage that I am aware of, but when writing scripts, one might as well do it in a way considered best practice. GNUisms is a slang term for code which assumes use of GNU tools. Like adding the option -fPIC to the compiler, or the -a option to the 'cp' command. To my knowledge, there is no other Unix system which implements the '-a' option to the 'cp' command, or any other compiler which uses -fPIC. Dave > On Dec 8, 11:24 am, "Dr. David Kirkby" <[email protected]> > wrote: >> Many scripts have in them something like >> >> if [ $SAGE64 = "yes" -a $UNAME = "Darwin" ] ; then >> some code >> fi >> >> Where the '-a' means 'AND'. >> >> The use of the '-a' option is deprecated by both by the >> 2004http://www.opengroup.org/onlinepubs/009695399/utilities/test.html >> >> and 2008http://www.opengroup.org/onlinepubs/9699919799/utilities/test.html >> >> POSIX standards. (Possibly earlier standards too). >> >> The above should be written as >> >> if [ $SAGE64 = "yes" ] && [ $UNAME = "Darwin" ] ; then >> CFLAGS = "$CFLAGS -m64" >> fi >> >> (Actually, this SAGE64 and Darwin is one bit of code I really dislike, but >> that >> is only an issue for portability to Solaris, nothing to do with the test.) >> >> Likewise, the -o option is too, so >> >> test expr1 -o expr2 >> >> should be replaced by >> >> test expr1 || test expr2 >> >> I'm not suggesting everyone convert all their scripts, but when writing >> them, it >> would be wise to bear that in mind. The rationale for preferring the && or || >> operator is explained in the documents I linked above. >> >> Dave > -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
