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: > > 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? The echo -e should be a simple replace with printf "%b\n", but the code using file descriptor 3 and the bash feature to open a tcp socket, needs some more work, it can be replaced with nc, but the problem is that I have no Alibaba Cloud VM to test a fix on. > > Also I really wish there was a way to detect this while still using > bash. Maybe we can use bash --posix during tests? I am using checkbashisms[1] to check for these issues during Alpine packaging of virt-what[2]. / Henrik [1] https://salsa.debian.org/debian/devscripts/-/blob/master/scripts/checkbashisms.pl [2] https://git.alpinelinux.org/aports/tree/community/virt-what/APKBUILD#n34