shell script implementation of man

walter harms wharms at bfs.de
Sun Nov 23 13:06:36 UTC 2008



Cathey, Jim schrieb:
>> case "$pagefile" in
>> *.bz2)
>>        bzcat "$pagefile" | "$PAGER" ;;
>> *.gz)
>>        zcat "$pagefile" | "$PAGER" ;;
>> *)
>>        "$PAGER" "$pagefile" ;;
>> esac
>>
>> paths=
>> pagefile=
>> pagearg=
>> section=
> 
> 
> If there is no further work (and I don't see any), is it
> not appropriate to "exec" the last step, thus eliminating
> one extra process (the shell)?  Viz:
> 
> case "$pagefile" in
> *.bz2)
>         exec bzcat "$pagefile" | "$PAGER" ;;
> *.gz)
>         exec zcat "$pagefile" | "$PAGER" ;;
> *)
>         exec "$PAGER" "$pagefile" ;;
> esac
> 
> -- Jim
> 



just to provide an alternative way:

 case "$pagefile" in
 *.bz2)
         CAT="bzcat" ;;
 *.gz)
         CAT="zcat" ;;
 *)
         CAT="cat"  ;;
 esac

"$CAT" "$pagefile" | "$PAGER" "$pagefile"

this can easily be expanded to dot-whatever-you-like


re,
 wh




More information about the busybox mailing list