Bug#987669: kpartx: bashism in /bin/sh script (kpartx_id)
On Wed, Apr 28, 2021 at 10:09:02PM +0530, Ritesh Raj Sarraf wrote: > On Tue, 2021-04-27 at 15:52 +0200, Julien Cristau wrote: > > > > Apr 27 13:44:47 ubc-enc2bl10/ubc-enc2bl10 systemd-udevd[50553]: > > 'kpartx_id 254 29 mpath-3600c0ff00027786c559a785d0100'(err) > > '/lib/udev/kpartx_id: 96: /lib/udev/kpartx_id: [[: not found' > > > > /lib/udev/kpartx_id has a /bin/sh shebang, [[ is a bashism, so should > > probably be replaced with the standard "test -n". > > > Maybe I'm doing something very silly. But I don't get the desired > output with "test -n" > You need to quote "$x" and "$y". Cheers, Julien
Bug#987669: kpartx: bashism in /bin/sh script (kpartx_id)
On Tue, 2021-04-27 at 15:52 +0200, Julien Cristau wrote: > > Apr 27 13:44:47 ubc-enc2bl10/ubc-enc2bl10 systemd-udevd[50553]: > 'kpartx_id 254 29 mpath-3600c0ff00027786c559a785d0100'(err) > '/lib/udev/kpartx_id: 96: /lib/udev/kpartx_id: [[: not found' > > /lib/udev/kpartx_id has a /bin/sh shebang, [[ is a bashism, so should > probably be replaced with the standard "test -n". Maybe I'm doing something very silly. But I don't get the desired output with "test -n" rrs@priyasi:~$ cat /tmp/string.sh #!/bin/dash x="Ritesh" y= if [ -n $x ]; then echo Yes fi if [ -n $y ]; then echo Yes fi test -n $x && echo Yes test -n $y && echo Yes rrs@priyasi:~$ /tmp/string.sh Yes Yes Yes Yes I rather propose this commit. commit 7d3a38a2efd955e17b43edd43e866c8705f7d570 (HEAD -> patch- queue/wip/ritesh/fix-bashism) Author: Ritesh Raj Sarraf Date: Wed Apr 28 22:06:50 2021 +0530 Fix bashism in kpartx_id script Thanks: Julien Cristau Closes: #987669 diff --git a/kpartx/kpartx_id b/kpartx/kpartx_id index c45db2f8..e8448674 100755 --- a/kpartx/kpartx_id +++ b/kpartx/kpartx_id @@ -93,7 +93,7 @@ if [ -n "$dmdeps" ] ; then else echo "DM_TYPE=raid" fi -if [[ $dmserial ]]; then +if ! [ -z $dmserial ]; then echo "DM_SERIAL=$dmserial" fi -- Ritesh Raj Sarraf | http://people.debian.org/~rrs Debian - The Universal Operating System signature.asc Description: This is a digitally signed message part
Bug#987669: kpartx: bashism in /bin/sh script (kpartx_id)
Package: kpartx Version: 0.8.5-1 Severity: important Apr 27 13:44:47 ubc-enc2bl10/ubc-enc2bl10 systemd-udevd[50553]: 'kpartx_id 254 29 mpath-3600c0ff00027786c559a785d0100'(err) '/lib/udev/kpartx_id: 96: /lib/udev/kpartx_id: [[: not found' /lib/udev/kpartx_id has a /bin/sh shebang, [[ is a bashism, so should probably be replaced with the standard "test -n". Cheers, Julien