kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2] configure: arm/arm64: Add --earlycon option to set UART type and address
Date: Fri, 19 Mar 2021 12:57:20 +0100	[thread overview]
Message-ID: <20210319115720.vjuvi6rxebhyrdo7@kamzik.brq.redhat.com> (raw)
In-Reply-To: <d8403f28-c47c-d8eb-4131-c13a1fdd9a73@arm.com>

On Fri, Mar 19, 2021 at 11:37:51AM +0000, Alexandru Elisei wrote:
> > You can also drop 'cut' and just do something like
> >
> > IFS=, read -r name type_addr addr <<<"$earlycon"
> 
> That looks much nicer and concise, and I prefer it to my approach.
> 
> However, I believe it requires a certain version of bash to work. On bash 5.1.4
> and 4.3.48 (copyright says it's from 2013), it works as expected. On bash 3.2.57
> (version used by MacOS), the result of the command is that the variable name
> contains the string with the comma replaced by space, and the other variables are
> empty. Using cut works with this version. According to the copyright notice, bash
> 3.2.57 is from 2007, so extremely old.
> 
> Did some googling for the query "bash split string" and according to this stack
> overflow question [1] (second reply), using IFS works for bash >= 4.2. Don't know
> how accurate it is.
> 
> I guess the question here is how compatible we want to be with regard to the bash
> version. I am not familiar with bash programming, so I will defer to your decision.

From time to time we've had this come up with kvm-unit-tests. The result
has always been to say "yeah, we should figure out our minimally required
Bash version and document that", but then we never do... It sounds like
you've identified Bash 4.2 being required for this IFS idiom. As we
already use this idiom in other places in kvm-unit-tests, then I think
the right thing to do is to test running all the current scripts with
Bash 4.2, and if that works, finally document it. I'll do that ASAP.

> > And/or should we do a quick sanity check on the address?
> > Something like
> >
> >   [[ $addr =~ ^0?x?[0-9a-f]+$ ]]
> 
> Another great suggestion. The pattern above doesn't take into account character
> case and the fact that 0xa is a valid number, but a is not. Best I could come up
> with is:
> 
> [[ $addr =~ ^0(x|X)[0-9a-fA-F]+$ ]] || [[ $addr =~ ^[0-9]+$ ]]
> 
> What do you think?

LGTM

Thanks,
drew


      reply	other threads:[~2021-03-19 11:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 16:20 [kvm-unit-tests PATCH v2] configure: arm/arm64: Add --earlycon option to set UART type and address Alexandru Elisei
2021-03-18 16:41 ` Andrew Jones
2021-03-19 11:37   ` Alexandru Elisei
2021-03-19 11:57     ` Andrew Jones [this message]

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=20210319115720.vjuvi6rxebhyrdo7@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=pbonzini@redhat.com \
    /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.
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).