9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Ethan Gardener" <eekee57@fastmail.fm>
To: 9fans@9fans.net
Subject: `test -x` returns wrong results for directories
Date: Fri, 05 Jun 2020 13:45:14 +0100	[thread overview]
Message-ID: <e6adcb73-2da9-4ae0-b49d-85e14d9543e9@www.fastmail.com> (raw)

in rc-httpd, i rely on `test -x` to check if a directory is searchable. this works in plan9port, 9base, inferno (with root from host fs), gnu coreutils, and freebsd. it doesn't work in 9front, nor in labs plan 9. (the labs version tested was a live-cd from 2010.)

term% test -x static ; echo $status
test 13436: false
term% ls -ld static
d-rwxrwxr-x M 24 ethan adm 0 Mar 15 14:58 static
term% man 1 test | grep -- -x
          -x file    True if the file exists and has execute permis-
term% 

the word 'wrong' in the subject may be a little strong, but there doesn't seem to be an alternative test for searchable directories other than mucking about with ls -l | sed or awk. test(1) has nothing to say on the matter.

for anyone using rc-httpd, the intended logic in rc-httpd/handlers/dir-index is this:
	if(! test -r $full_path -a -x $full_path) {
a suitable workaround is to remove ` -a -x $full_path`.
9front's version of rc-http has a workaround which may break when test is fixed.
/rc/bin/rc-httpd/handlers/dir-index:/-x
	if(! test -r $full_path -x $full_path){
in plan 9 and gnu coreutils, this effectively replaces the logical and (-a) with a logical or. freebsd reports an error, 'unexpected operator'.

             reply	other threads:[~2020-06-05 12:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 12:45 Ethan Gardener [this message]
2020-06-05 19:22 ` [9fans] " Richard Miller
2020-06-06  6:36   ` Ethan Gardener
2020-06-06 12:11     ` Alexander Kapshuk
2020-06-06 13:25     ` Charles Forsyth
2020-06-07 13:56       ` Ethan Gardener
2020-06-06 21:13     ` ori
2020-06-07 14:48       ` Ethan Gardener
2020-06-07 15:41         ` Richard Miller
2020-06-08  2:04           ` ori
2020-06-08  2:13             ` Charles Forsyth
2020-06-08  2:20               ` Charles Forsyth
2020-06-09 10:50               ` Ethan Gardener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6adcb73-2da9-4ae0-b49d-85e14d9543e9@www.fastmail.com \
    --to=eekee57@fastmail.fm \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).