9front - general discussion about 9front
 help / color / mirror / Atom feed
* test -x broken & rc-httpd has broken workaround
@ 2020-03-15 17:55 Ethan Gardener
  2020-06-05 12:47 ` [9front] " Ethan Gardener
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Gardener @ 2020-03-15 17:55 UTC (permalink / raw)
  To: 9front

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% 

/rc/bin/rc-httpd/handlers/dir-index has a broken workaround for this. the workaround is to omit a necessary -a like so:
    if(! test -r $full_path -x $full_path){
it should be:
    if(! test -r $full_path -a -x $full_path) {
evidently, omitting -a (and) makes it default to logical or, breaking the logic of this line. (this default in the absence of -a or -o is undocumented in plan 9 & gnu.) the indended logic (with -a) is useful, it helps with debugging folder permissions.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] test -x broken & rc-httpd has broken workaround
  2020-03-15 17:55 test -x broken & rc-httpd has broken workaround Ethan Gardener
@ 2020-06-05 12:47 ` Ethan Gardener
  0 siblings, 0 replies; 2+ messages in thread
From: Ethan Gardener @ 2020-06-05 12:47 UTC (permalink / raw)
  To: 9front

i'm sorry for my previous complaint. this is not specific to 9front, but was present in labs '9 before 9front was forked.

for those who don't read 9fans, here's a full report i just posted there:

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 '[broken]' 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'.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-05 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 17:55 test -x broken & rc-httpd has broken workaround Ethan Gardener
2020-06-05 12:47 ` [9front] " Ethan Gardener

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).