Re: [kvm-unit-tests PATCH v2] configure: arm/arm64: Add --earlycon option to set UART type and address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux