[SM-Discuss] Spell branches
Ismael Luceno
ismael.luceno at gmail.com
Tue Sep 13 03:34:15 EDT 2011
El Tue, 13 Sep 2011 08:26:09 +0900
flux <flux at sourcemage.org> escribió:
<...>
> A slightly improved version of the code is as follows:
>
> function select_branch() {
> local spell="$1" tmp &&
> shift &&
>
> if [[ "$#" > 1 ]]; then
> config_query_list "$spell"_BRANCH \
> "Select one of the available branches:" "$@"
> else
> eval "$spell"_BRANCH=\""$spell"\"
> fi &&
>
> eval tmp=\"\$"$spell"_BRANCH\" &&
>
> if [[ "$tmp" != "$spell" && "${tmp/-*}" = "scm" ]]; then
> config_query "$spell"_SCM_AUTOUPDATE \
> 'Update on every system update?' n
> fi
> }
>
> This is more "correct" in that a spell named scm-foo wouldn't
> erroneously trigger the second if block to succeed. It's also a bit
> more readable in how tmp gets set (and uses the "$spell" variable
> instead of $1, so the value is more readable as well).
$1 != $spell, 3rd line.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/sm-discuss/attachments/20110913/80877bce/attachment.bin
More information about the SM-Discuss
mailing list