:: Re: [DNG] desktop-base package revi…
Etusivu
Poista viesti
Vastaa
Lähettäjä: Ian Zimmerman
Päiväys:  
Vastaanottaja: dng
Aihe: Re: [DNG] desktop-base package review
On 2016-01-21 22:02 +0000, Rainer Weikusat wrote:

> update-boot(){
>     if [ -n $1 ]; then
>         case $1 in
>             commented)
>                 echo -e "\n$DEF_GRUB_COMMENT\n# $DEF_GRUB_SETTING" >> $DEFAULT_GRUB
>                 return
>                 ;;
>             *)
>                 echo -e "\n$DEF_GRUB_COMMENT\n$DEF_GRUB_SETTING" >> $DEFAULT_GRUB
>                 ;;
>         esac
>     fi     


> It should be possible to express this as (untested)
>
> update_boot() {
>     if [ "$1" = commented ]; then
>             echo -e "\n$DEF_GRUB_COMMENT\n# $DEF_GRUB_SETTING" >> $DEFAULT_GRUB
>                 return
>     fi               

>
>         echo -e "\n$DEF_GRUB_COMMENT\n$DEF_GRUB_SETTING" >>$DEFAULT_GRUB


This is of course pure bikeshedding, but in fact I prefer a case
statement (where possible, even with only one branch) to if-then,
because the former avoids the not-very-readable and frail test or []
syntax. I agree that the top-level test is redundant, of course.

> IMHO, considering the use of printf instead of echo -e is also
> worthwhile, as in
>
> printf '\n%s\n#% s\n' "$DEF_GRUB_COMMENT" "$DEF_GRUB_SETTING" >> $DEFAULT_GRUB


Definitely agreed.

>        while read confline; do
>             case confline in
>                 $DEF_GRUB_COMMENT)
>                     theme_default_conf=true;
>                     ;;
>                 $DEF_GRUB_SETTING)
>                     theme_parm="matching"
>                     ;;
>                 "#$DEF_GRUB_SETTING"|"# $DEF_GRUB_SETTING")
>                     theme_parm="disabled"
> ----------

>
> missing ;;
>
> ----------
>                 GRUB_THEME=*)
>                     theme_parm="modified"
>                     ;;
>             esac
>         done

>
> This reads from stdin which was probably not intended.


Right, and besides, looping over a read is bad style. Better do it with
sed or a series of greps.

--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.