[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Read Prompt Width Miscalculation (Non-Printing Characters)
From: |
Chet Ramey |
Subject: |
Re: Read Prompt Width Miscalculation (Non-Printing Characters) |
Date: |
Wed, 28 Dec 2022 20:20:35 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 |
On 12/28/22 2:09 PM, The Administrator wrote:
Hello and happy holiday hacking. Does the read builtin stand to benefit
from \[ and \] denotation ala $PS1 and friends? Here is a quick example:
read -erp "$( tput setaf 2 )NEW:$( tput sgr0 ) "
You can either use $'\001' and $'\002' in place of \[ and \], which is
what they end up expanding to for readline, or you can write your prompt
string as you would write PS1 and use the ${word@P} expansion when you
pass it as an argument to `read' (preferred).
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/