From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 38CEE299B7 for ; Mon, 4 Mar 2024 19:06:32 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709575592; b=VHHhuQ9u26KJ/CZCwxfQh2NB982mhXSJW1vnahtb1pn2c6qG3rpSRVP8azlMROhqzDQQoCG/Pr ZFGcCiFV2gHeVn0P8yB59xcD3O1Xj5yvOh3nHkVt+N+hxPuM3X5mW0yNLiRCa/xITOM2MBqlR3 cXOUwhBPCp4KlN4QT8S95xELcYqo7mHO2VR+ZgeBQyGC04yRZTpwO94+ae9r3Qtn/rIkjd0V6c AjWLhRnK6Hk82QRWLbZHbidByWkBdjfrAENlKq1PWSFYC1/v8pDtLvP6w95IIR/1K+D+XyQgG6 eRudogNtIcxCjs+hCdGxmpAfB7OWRYveWHKFq5Jxb6H/LQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709575592; bh=vPJgjaWdvEd97hRCIZdWhetMq/NWb11oOhkU0+d6JPM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=HIRxymVzZeTOs2+uQVdw8YhvpEZj83EdGIxr0XRNZ2+TDEU0Bo1NRkRkdyd0dOqDJeFCeHKkOA 6GxRjyI5Qvjt8FDH52tqHDtYGhUUWpQvGPZKzIPC9J12wn+SxM2ue1H5EQLpKTAFhByMtLsh3e 0z4hlLVInJobwe1E1pVs5mjcINxgniemg/uU96BJyvRVRH8ZZS9lxqZ3bsBknC2MtQtj4Rlqvo j1XdtTRgA5nyOyzCllfXWc5nNwiCxm9O3d5/IPOSnAs4OFdlyz3eTH3pXF9bK8+yjKQxJItWYj ZgJRl7NTgWONzvEJuay1BA07eL9dtpx7Tf9TihVPh91rwQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6gNDAigXycygQiTzCMrY6jhZuHp9YtilDvFYl7bDrnc=; b=Cu6MIUcS2immAmqaNuo3RRbM/I 1cwnnnqIGRgkW6VrW2w+/c7iJhJoh0uGjE4Kbdux3pxs2Vay0prn46tiSBo0+aJlaTBK60Tk0ig6A aZE2exe/tVSswqWFf5Rue1JPKrgmDjK384we8CuK1zS37QDXCi272C4LPUw3L5ijIC1ZTJYo4q+5m Uwzch6bxRkj/y+StORHWRB1G8mDk29Zbi1kzQnhC44bArr7rYgyB8EtAmyCXxKIyYDdkfwYIXUB69 WZqJ9QOq7oxRhmvb0qAB4SUA80xlzlhn6y/omcuV61OEX5580Mi70zdU4hg0VhWoJ/oOsNmkjCImb gqEdtXGg==; Received: by zero.zsh.org with local id 1rhChq-000Ea1-Kn; Mon, 04 Mar 2024 18:06:30 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f49.google.com ([209.85.218.49]:46232) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rhCha-000EFh-4b; Mon, 04 Mar 2024 18:06:14 +0000 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a4595bd5f8cso23264666b.0 for ; Mon, 04 Mar 2024 10:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709575573; x=1710180373; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6gNDAigXycygQiTzCMrY6jhZuHp9YtilDvFYl7bDrnc=; b=mfbePevLCLJPQTZBMNtHzgIg9uwJB8Yn9wg3biztg0skhI436iT/sFUl8CSUK5fk3U 4IEL9BjFwKw5TgsDyElpN3ZBy6DHvuEvzhPmLOBMLetX8DFWHSDj6IIb69LlU+c/I+se 1VBLt+pUUZwdY0ypWWWVSy2OKnycycCRl9NRO/IqrRnhWkVBCfVzuNYV0aZ9RGsimqXU LoYFFsq5PS04U5tAyqDgqXPshZG6PNQBWjSTt+DTsV9gJbuwUTQhnm3p0ekOdoDgTLd2 5nyFEAamxhdEALmys/FQuqm9QoRab3ojuxQbT72thkXvRsJ7jwD7pG82QhS5q97RKYhC c/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709575573; x=1710180373; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6gNDAigXycygQiTzCMrY6jhZuHp9YtilDvFYl7bDrnc=; b=HKGokjjCuyl3/xhLVX9rIE10Wslj9RFq6VjGQsTMaYkka9rAG5JsAdKe8p4fRxq/Sa ETNCo1gSLWTvYJu1zhJEMf8Y2x2OV0elKNNlg0YhFTzQaXeL47rJPe6caw4Xo0pPZt1i 4SEg9i7gKX10DhY7lzAex4VC0BmiA3ZF2BzduSQE9TVpfinbPltRddOQn70UmQIsnzFo paAidODLmluZFgjgcRjguNfos9gfHo9xmKJpMkrmSf2WbWkaF8vQm7fl++2WMcFLdfL0 FQGD0UCh2DoxQjk7n9tN2nH+sFgzDVtFLjENzC4p+Lq+TU8m5Xo2ffG6EaL7UTlI0FGu 1Y+A== X-Gm-Message-State: AOJu0Yzvg7/q3WbxO9LKcIdGGrgdGy0xkghlQOQrpGK1DQNIG0ND8UZP NvnxDBL6KbjfYbMVD1iggWYH5QNaX62zuU5bpHFVE4Yohsww0+Jdw27ohb5pCh5HrHmYt8UWpfF eCavwL4FWI3mY7aX6rP+m7AUcsNA= X-Google-Smtp-Source: AGHT+IGlvAuvN6XYWxuK3TR0wVIfcbXSvfq2QfUiJ0Xn/zO01hDMU81cD6CQc8e63yQZtq55LeuRZHx1Pr+GNenchcY= X-Received: by 2002:a17:906:6813:b0:a44:51d8:7dd with SMTP id k19-20020a170906681300b00a4451d807ddmr6914037ejr.0.1709575573064; Mon, 04 Mar 2024 10:06:13 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:7208:5351:b0:7f:2ef1:5159 with HTTP; Mon, 4 Mar 2024 10:06:12 -0800 (PST) In-Reply-To: References: From: Mikael Magnusson Date: Mon, 4 Mar 2024 19:06:12 +0100 Message-ID: Subject: Re: What appears to be inconsistent results from ${(%):-%F{${subscript}} To: linuxtechguy@gmail.com Cc: devs Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52666 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 3/4/24, Jim wrote: > Hi all, > > Output for the following function will help visualize what I believe to = be > inconsistencies of the output of ${(%):-%F{${subscript}}. > I would assume %B (background) would yield similar results. > > Note the function outputs a solid block character in color. > Hopefully the block charcter will cut and paste correctly. > > color_conversion_check () { > local subscript colorconversion > local subscripts > subscripts=3D(black blue cyan default gray green grey magenta red white > yellow > bright-blue bright-cyan bright-gray bright-green bright-grey > bright-magenta > bright-red bright-white bright-yellow > 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 > 16 17 18 229 230 231 > 232 233 234 253 254 255 > '#000000' '#007fff' '#ff0080' '#abcdef' '#007FFF' '#FF0080' '#ABCDEF' > ) > print -- "Output of fg associative array" > print -- "${fg[gray]}${(r.24..=E2=96=88.)}\e[0m ${(V)fg[gray]} fg[gr= ay]" > print -- "${fg[grey]}${(r.24..=E2=96=88.)}\e[0m ${(V)fg[grey]} fg[gr= ey]" > print -- > for subscript ($subscripts) { > colorconversion=3D"${(%):-%F{${subscript}}" > print -- "${(%)colorconversion}${(r.24..=E2=96=88.)}\e[0m > ${(V)colorconversion} ${subscript}" > } > } > > First, '${(%):-%F{${subscript}}' has unbalanced curly brackets({}), but > still works. > Adding a closing bracket(}) results in '}' being added to the output. So > instead of > getting ',,,m' you get '...m}'. I'm confused. What am I missing? This is a common-ish pitfall. When in double quotes, { and } are not special to the shell, so the first } matches the opening { from ${. You then have an extraneous } which is printed as normal. > To my original point > > 1) the color names grey and gray do not output black but output the > default The available colors are: black, red, green, yellow, blue, magenta, cyan and white. > 2) bright color names are not converted but output the default color > Should bright color names be added to the code? ANSI only guarantees 8 colors are available. > 3) using decimal numbers(0-255) > 0 - 15 uses 30-27 and 90-97(bright) instead of using the colors > defined > by the terminal > NOTE: 0-15 are defined even for TERM=3Dlinux > 16-255 uses the colors defined by the terminal > Is there a reason why it doesn't use the terminal colors for 0-15? I have no idea what you mean by this. --=20 Mikael Magnusson