[act] UBUNTU: SAUCE: ubuntu_btrfs_kernel_fixes: fix "if" statement
diff mbox series

Message ID 20190916135445.18899-1-jesse.sung@canonical.com
State New
Headers show
Series
  • [act] UBUNTU: SAUCE: ubuntu_btrfs_kernel_fixes: fix "if" statement
Related show

Commit Message

Wen-chien Jesse Sung Sept. 16, 2019, 1:54 p.m. UTC
BugLink: https://launchpad.net/bugs/1813534

The test complains about "line 58: [: -gt: unary operator expected".

Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
---
 .../fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thadeu Lima de Souza Cascardo Sept. 16, 2019, 2:04 p.m. UTC | #1
On Mon, Sep 16, 2019 at 09:54:45PM +0800, Wen-chien Jesse Sung wrote:
> 
> BugLink: https://launchpad.net/bugs/1813534
> 
> The test complains about "line 58: [: -gt: unary operator expected".
> 
> Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
> ---
>  .../fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh           | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

> diff --git a/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh b/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
> index c3bd6a7..9513f69 100755
> --- a/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
> +++ b/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
> @@ -55,7 +55,7 @@ wait $pid
>  
>  umount $DEV0
>  n=$(btrfsck $DEV0 | grep "errors")
> -if [ $n -gt 0 ]; then
> +if [[ $n -gt 0 ]]; then

I think the problem here is that it should be 'grep -c "errors"' instead.

Otherwise, this will fail to catch errors as [ "errors" -gt 0 ] test fail, when
we want that to succeed whenever we find "errors" on the output of btrfsck.

Cascardo.

>  	echo "failed, btrfsck found some errors"
>  	rc=1
>  else

Patch
diff mbox series

diff --git a/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh b/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
index c3bd6a7..9513f69 100755
--- a/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
+++ b/ubuntu_btrfs_kernel_fixes/fixes/b9a8cc5bef963b76c5b6c3016b7e91988a3e758b.sh
@@ -55,7 +55,7 @@  wait $pid
 
 umount $DEV0
 n=$(btrfsck $DEV0 | grep "errors")
-if [ $n -gt 0 ]; then
+if [[ $n -gt 0 ]]; then
 	echo "failed, btrfsck found some errors"
 	rc=1
 else