Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fh0h4-00028E-Ik for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jul 2018 22:49:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fh0h2-0001il-Nq for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jul 2018 22:49:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fh0h2-0001ie-H4 for pgsql-hackers@lists.postgresql.org; Sat, 21 Jul 2018 22:49:40 +0000 Received: from www1.webmail.pair.com ([209.68.6.94]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fh0gy-0000Wm-Va for pgsql-hackers@postgresql.org; Sat, 21 Jul 2018 22:49:39 +0000 Received: by www1.webmail.pair.com (Postfix, from userid 65534) id DDD56700277; Sat, 21 Jul 2018 18:49:33 -0400 (EDT) Received: from 78.34.183.51 ([78.34.183.51]) (SquirrelMail authenticated user te_123@bloodgate.com) by sm.webmail.pair.com with HTTP; Sat, 21 Jul 2018 18:49:33 -0400 Message-ID: <4aca1a4e7e8e82513988a7236e227c2d.squirrel@sm.webmail.pair.com> In-Reply-To: References: <20180720153820.69e9ae6c@fafnir.local.vm> <17833.1532096747@sss.pgh.pa.us> <20180720175508.07776219@fafnir.local.vm> <4263.1532186967@sss.pgh.pa.us> Date: Sat, 21 Jul 2018 18:49:33 -0400 Subject: Re: Non-portable shell code in pg_upgrade tap tests From: "Tels" To: =?utf-8?B?IkRhZ2Zpbm4gSWxtYXJpIE1hbm5zw6VrZXIi?= Cc: "Tom Lane" , "Victor Wagner" , "pgsql-hackers" User-Agent: SquirrelMail/1.4.23 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Moin, On Sat, July 21, 2018 12:47 pm, Dagfinn Ilmari Mannsåker wrote: > Tom Lane writes: > >> "Tels" writes: >>> + *) if [ `find ${PGDATA} -type f ! -perm 640 | wc -l` -ne 0 ]; then >> >>> Shouldn't ${PGDATA} in the above as argument to find be quoted, >>> otherwise >>> the shell would get confused if it contains spaces or other special >>> characters? >> >> Hmm. Yeah, probably. I don't think this script is meant to be run with >> arbitrary values of PGDATA, but most of the other uses are quoted, so >> for consistency's sake this should be too. > > PGDATA is built from `pwd`, so it breaks if the build directory has a > space in it. Because it's testing for the absence of files, it doesn't > actually break the test, but would fail to detect the bugs it's trying > to. Thanx for the fix. But perhaps I should have been a bit more specific in my first message, spaces are not the only character this can break at. Looking at your new patch, I notice you used "" for quoting, not ''. (Not sure which variant Tom used when pushing a patch). I'm not a shell expert, but I think '' are safer, as "" still has some interpolation from the shell (at least on the systems I use regulary): te@pc:~$ mkdir 'test$test' te@pc:~$ touch 'test$test/test' te@pc:~$ find 'test$test/test' -type f test$test/test te@pc:~$ find "test$test/test" -type f find: ‘test/test’: No such file or directory So I've grown the habit to always use '' instead of "". Not sure if this is specific to bash vs. sh or PC vs Mac, tho. Best wishes, Tels