Notice: the grml team is migrating from Mercurial to Git.
Please visit git.grml.org instead!
| author | Michael Prokop <mika@grml.org> |
| Sun Dec 16 20:08:03 2007 +0100 (11 months ago) | |
| changeset 7 | c27f263aea47 |
| manifest | c27f263aea47 |
| parent 6 | 3c526bc24450 |
| tag | tip |
--- a/grml-policy.txt Mon Nov 19 00:35:36 2007 +0100+++ b/grml-policy.txt Sun Dec 16 20:08:03 2007 +0100@@ -77,9 +77,12 @@ the grml-team you can checkout the accorthe grml-team you can checkout the according repository and create a patchusing the 'hg diff' command. Usage example:- hg clone http://hg.grml.org/grml-policy- cd grml-policy- hg diff > update_for_grml-policy-mention_foobar.diff+[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+hg clone http://hg.grml.org/grml-policy+cd grml-policy+hg diff > update_for_grml-policy-mention_foobar.diff+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~And mail the resulting diff to the grml-team. The maintainer of theaccording repository is listed in the Contact-column on@@ -130,12 +133,15 @@ scripts (like shellscripts handling withscripts (like shellscripts handling with services) and is supposed to bePOSIX-compatible. Usage example:- % source /etc/grml/lsb-functions- % einfo "Starting foobar." ; /bin/true ; eend $?- * Starting foobar. [ ok ]- % einfo "Starting foobar." ; /bin/false ; eend $?- * Starting foobar. [ !! ]- %+[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+% source /etc/grml/lsb-functions+% einfo "Starting foobar." ; /bin/true ; eend $?+ * Starting foobar. [ ok ]+% einfo "Starting foobar." ; /bin/false ; eend $?+ * Starting foobar. [ !! ]+%+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~If you want to provide output on the plain console (without using aninterface like link:http://invisible-island.net/dialog/[dialog] or@@ -175,16 +181,19 @@ check4root function provided by /etc/grm* **clean up when being interrupted and on exit:** your script should not leaveany temporary files (unless intented for debugging purposes of course).Usage example:-- TMPFILE=$(mktemp ${TMP}/grml2hd.XXXXXX)- bailout() {- rm -f "$TMPFILE"- [ -n "$1" ] && EXIT="$1" || EXIT="1"- exit "$EXIT"- }- trap bailout 1 2 3 15- $CODE- bailout 0+++[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+TMPFILE=$(mktemp ${TMP}/grml2hd.XXXXXX)+bailout() {+ rm -f "$TMPFILE"+ [ -n "$1" ] && EXIT="$1" || EXIT="1"+ exit "$EXIT"+}+trap bailout 1 2 3 15+$CODE+bailout 0+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* **use of subshells:** please use _$(...)_ instead of _\`...\`_.+@@ -195,17 +204,23 @@ would end the quotes immediately.would end the quotes immediately.+Consider the following as an example on readability:-- % echo "Tomorrow's date: `expr \`date +%d\` + 1`.`date +%m`."- % echo "Tomorrow's date: $(expr $(date +%d) + 1).$(date +%m)."+++[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+% echo "Tomorrow's date: `expr \`date +%d\` + 1`.`date +%m`."+% echo "Tomorrow's date: $(expr $(date +%d) + 1).$(date +%m)."+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+Furthermore it can get quite tricky to get the right level of quoteswhen using backquotes.-- % print "`echo \"hello\"`"- hello- % print "$(echo \"hello\")"- "hello"+++[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+% print "`echo \"hello\"`"+hello+% print "$(echo \"hello\")"+"hello"+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+For further reading have a look atlink:http://zsh.dotsrc.org/Guide/zshguide05.html#l11[A User's Guide to the@@ -215,24 +230,27 @@ the Z Shell]* **if ... then ... else ...**: you should make sure that the code is aseasy understandable as possible. So instead of using:-- if [ -n "$FOO" ] ; then- foo- bar- bla- else- baz- fi-- you should consider use of:-- if [ -z "$FOO" ] ; then- baz- else- foo- bar- bla- fi+++[shell]+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+if [ -n "$FOO" ] ; then+ foo+ bar+ bla+else+ baz+fi++you should consider use of:++if [ -z "$FOO" ] ; then+ baz+else+ foo+ bar+ bla+fi+source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* **indenting:** make sure you indent your code and use blank lines whereaccording. Commonly accepted textwidth is 80 chars. (TODO: provide some