Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to compare for control codes in a string



On Thu, Oct 12, 2023 at 11:39 AM henman <dhenman@xxxxxxxxx> wrote:
>
>     if [[ $line[1] == '\f' ]]    # Check if the 1st character is a formfeed

That's checking for the two literal characters backslash and f which
will never match a single character as in $line[1].  You probably
meant

     if [[ $line[1] == $'\f' ]]    # Check if the 1st character is a formfeed

Except with $'...', processing of \f \t \n etc. is not done as part of
string interpolation, though you might be fooled into thinking so
because it may instead be done by the print and echo commands.

>         then tmpline=${line[@]:1}  # strip the ^f off

The [@] there doesn't mean anything when $line is not an array, though
it's harmless.




Messages sorted by: Reverse Date, Date, Thread, Author