zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: henman <dhenman@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: How to compare for control codes in a string
Date: Thu, 12 Oct 2023 11:51:32 -0700	[thread overview]
Message-ID: <CAH+w=7ZWO939wfz_NBdQtXE=JEPAnkHy+3OsQ02ckXSN82aeAw@mail.gmail.com> (raw)
In-Reply-To: <CAC2FHtSqa02G85+ty_d2x+M3EufNbsXjrsg1TkeU3ia9zf9U3g@mail.gmail.com>

On Thu, Oct 12, 2023 at 11:39 AM henman <dhenman@gmail.com> 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.


  reply	other threads:[~2023-10-12 18:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 18:39 henman
2023-10-12 18:51 ` Bart Schaefer [this message]
2023-10-12 22:22 ` Pier Paolo Grassi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZWO939wfz_NBdQtXE=JEPAnkHy+3OsQ02ckXSN82aeAw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=dhenman@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).