From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: network@lists.ipfire.org Subject: Re: [PATCH 4/6] cli: print the color of a zone/port Date: Wed, 14 Jun 2017 22:06:50 +0100 Message-ID: <1497474410.2416.13.camel@ipfire.org> In-Reply-To: <1497003452-10190-4-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6771827014897548483==" List-Id: --===============6771827014897548483== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Hi, On Fri, 2017-06-09 at 12:17 +0200, Jonatan Schlag wrote: > Signed-off-by: Jonatan Schlag > --- >  src/functions/functions.cli | 18 ++++++++++++++++++ >  1 file changed, 18 insertions(+) > > diff --git a/src/functions/functions.cli > b/src/functions/functions.cli > index a4690b2..cd4fd06 100644 > --- a/src/functions/functions.cli > +++ b/src/functions/functions.cli > @@ -112,6 +112,12 @@ cli_device_headline() { >   ;; >   esac >   cli_print_fmt1 1 "Status" "${status}" > + > + # Print the color of the device. > + if [[ "${type}" == "zone" ]] || [[ "${type}" == "port" ]]; > then > + cli_print_fmt1 1 "Color " "$(cli_color ${type} > ${device})" > + fi > + To compare two string values in shell you actually only use = instead of ==. I would probably have written this as: case "${type}" in port|zone) ... ;; esac I always considered this performing faster. >   if enabled long; then >   cli_print_fmt1 1 "Address" "$(device_get_address > ${device})" >   fi > @@ -423,3 +429,15 @@ cli_show_man() { >   >   man ${manpage} >  } > + > + > +cli_color() { Whitespace again :) > + assert [ $# -eq 2 ] > + > + local type=${1} > + local name=${2} > + > + local color=$(color_read ${type} ${name}) > + > + echo "$(shell_set_color - ${color})            ${CLR_RESET}" > +} --===============6771827014897548483== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjIKCmlRSWNCQUFC Q2dBR0JRSlpRYVZxQUFvSkV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