From patchwork Wed Oct 14 13:22:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 7395561 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6161C9F36A for ; Wed, 14 Oct 2015 13:22:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 808252085D for ; Wed, 14 Oct 2015 13:22:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CDC620755 for ; Wed, 14 Oct 2015 13:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753756AbbJNNWj (ORCPT ); Wed, 14 Oct 2015 09:22:39 -0400 Received: from sandeen.net ([63.231.237.45]:34952 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753293AbbJNNWj (ORCPT ); Wed, 14 Oct 2015 09:22:39 -0400 Received: from liberator.sandeen.net (liberator.sandeen.net [10.0.0.4]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id 5D40363C3CA2 for ; Wed, 14 Oct 2015 08:22:38 -0500 (CDT) To: fstests From: Eric Sandeen Subject: [PATCH resend] properly quote strings tested with -n Message-ID: <561E571D.3010500@sandeen.net> Date: Wed, 14 Oct 2015 08:22:37 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Per the Advanced Bash Scripting Guide: "The -n test requires that the string be quoted within the test brackets. Using an unquoted string with ! -z, or even just the unquoted string alone within test bracket normally works, however, this is an unsafe practice. Always quote a tested string." And indeed: $ unset FOOBAR $ [ -n $FOOBAR ] || echo nope $ [ -n "$FOOBAR" ] || echo nope nope Ran into this on a box w/o the attr program installed, and passed _require_attrs. Quoting the string fixes this; fix it there and other occurrences in common/* as well. Signed-off-by: Eric Sandeen Reviewed-by: Alex Elder Reviewed-by: Eryu Guan --- -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/common/attr b/common/attr index 48c81cc..cc9cfda 100644 --- a/common/attr +++ b/common/attr @@ -165,7 +165,7 @@ _filter_aces_notypes() _require_acls() { - [ -n $CHACL_PROG ] || _notrun "chacl command not found" + [ -n "$CHACL_PROG" ] || _notrun "chacl command not found" # # Test if chacl is able to list ACLs on the target filesystems. On really @@ -196,9 +196,9 @@ _list_acl() _require_attrs() { - [ -n $ATTR_PROG ] || _notrun "attr command not found" - [ -n $GETFATTR_PROG ] || _notrun "getfattr command not found" - [ -n $SETFATTR_PROG ] || _notrun "setfattr command not found" + [ -n "$ATTR_PROG" ] || _notrun "attr command not found" + [ -n "$GETFATTR_PROG" ] || _notrun "getfattr command not found" + [ -n "$SETFATTR_PROG" ] || _notrun "setfattr command not found" # # Test if chacl is able to write an attribute on the target filesystems. diff --git a/common/quota b/common/quota index 23be4f8..658b1c3 100644 --- a/common/quota +++ b/common/quota @@ -26,7 +26,7 @@ # _require_quota() { - [ -n $QUOTA_PROG ] || _notrun "Quota user tools not installed" + [ -n "$QUOTA_PROG" ] || _notrun "Quota user tools not installed" case $FSTYP in ext2|ext3|ext4|ext4dev|reiserfs) @@ -74,7 +74,7 @@ _require_xfs_quota() if [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ]; then _notrun "Quotas not supported on realtime scratch device" fi - [ -n $XFS_QUOTA_PROG ] || _notrun "XFS quota user tools not installed" + [ -n "$XFS_QUOTA_PROG" ] || _notrun "XFS quota user tools not installed" } #