On Thu, Apr 21, 2022 at 1:11 PM Richard W.M. Jones <rjones@xxxxxxxxxx> wrote: > > On Thu, Apr 21, 2022 at 12:54:42PM +0200, Henrik Riomar wrote: > > On Wed, Apr 20, 2022 at 3:42 PM Richard W.M. Jones <rjones@xxxxxxxxxx> wrote: > > > > > > On Wed, Apr 20, 2022 at 09:33:03AM -0400, Cole Robinson wrote: > > > > On 4/19/22 1:25 PM, Henrik Riomar wrote: > > I now note that commit b7cc3d93a613ef6d0ac5ccd6e32cc3d66e057243, that > > is part of v1.22 introduced two bashisms: > > > > possible bashism in ./virt-what line 119 (echo -e): > > │ > > if ( { echo -e "GET /latest/meta-datainstance/instance-type > > HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" │ > > >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ) 2>/dev/null ; then │ > > possible bashism in ./virt-what line 119 (/dev/(tcp|udp)): > > │ > > if ( { echo -e "GET /latest/meta-datainstance/instance-type > > HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" │ > > >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ) 2>/dev/null ; then > > > > Can this be fixed? as that is the only bashisms in virt-what. > > Can you send a patch to fix it? > Not tested on Alibaba cloud but something like this could work, note the nc timeout is set to 1 second. --- a/virt-what.in +++ b/virt-what.in @@ -116,7 +116,7 @@ arch=$(uname -m | sed -e 's/i.86/i386/' | sed -e 's/arm.*/arm/') # Check for Alibaba Cloud if echo "$dmi" | grep -q 'Manufacturer: Alibaba'; then # Check for Alibaba Cloud ECS Bare Metal (EBM) Instance - if ( { echo -e "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" >&3; grep -sq 'ebm' <&3 ; } 3<> /dev/tcp/100.100.100.200/80 ) 2>/dev/null ; then + if ( printf "%b\n" "GET /latest/meta-datainstance/instance-type HTTP/1.0\r\nHost: 100.100.100.200\r\n\r" | nc -w1 100.100.100.200 80 | grep -sq 'ebm' ) 2>/dev/null ; then echo "alibaba_cloud-ebm" else echo "alibaba_cloud" / Henrik