Thread View: comp.unix.shell
10 messages
10 total messages
Started by Christian Weisgerber
Thu, 26 Nov 2026 19:18
The road not taken
Author: Christian Weisgerber
Date: Thu, 26 Nov 2026 19:18
Date: Thu, 26 Nov 2026 19:18
18 lines
1264 bytes
1264 bytes
Wolfram Schneider has just added the UNIX V1, V3, V4, V6, V8, and V10
man pages to
https://man.freebsd.org/cgi/man.cgi
V7 had already been there. Formatting may still be a work in progress.
Anyway, I took a peek at V6, and found this gem in the find(1) man
page:
BUGS
Syntax should be reconciled with _if_.
And if you look at if(1), you can see that there was no test(1)
command yet; if(1) directly supported a number of operators. Which
could have been unified with those of find(1) ... but history took
a different turn.
--
Christian "naddy" Weisgerber naddy@mips.inka.de
Re: The road not taken
Author: Lawrence D’Oliveiro
Date: Thu, 26 Nov 2026 21:09
Date: Thu, 26 Nov 2026 21:09
15 lines
1699 bytes
1699 bytes
On Thu, 26 Nov 2026 19:18:41 -0000 (UTC), Christian Weisgerber wrote: > Anyway, I took a peek at V6, and found this gem in the find(1) man > page: > > BUGS > Syntax should be reconciled with _if_. > > And if you look at if(1), you can see that there was no test(1) > command yet; if(1) directly supported a number of operators. Which > could have been unified with those of find(1) ... but history took a > different turn. How was that supposed to work, exactly? “if” is a shell builtin, and can have its own shell-specific syntax; “find” is not.
Re: The road not taken
Author: Kaz Kylheku
Date: Thu, 26 Nov 2026 22:45
Date: Thu, 26 Nov 2026 22:45
26 lines
2043 bytes
2043 bytes
On 2026-11-26, Christian Weisgerber <naddy@mips.inka.de> wrote: > Wolfram Schneider has just added the UNIX V1, V3, V4, V6, V8, and V10 > man pages to > https://man.freebsd.org/cgi/man.cgi > V7 had already been there. Formatting may still be a work in progress. > > Anyway, I took a peek at V6, and found this gem in the find(1) man > page: > > BUGS > Syntax should be reconciled with _if_. I realized this in the 1990s sometime. I wrote an alternative utility which I called search (the name has been taken since then, in all likelihood). The search utility used square brackets, something like: $ search [ name "*.txt or ... ] The above remark almost certainly refers to the issue that since find uses parentheses, they always have to be escaped as \( \) which is irskome to type and detracts from readability. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca
Re: The road not taken
Author: Christian Weisgerber
Date: Fri, 27 Nov 2026 00:15
Date: Fri, 27 Nov 2026 00:15
24 lines
1735 bytes
1735 bytes
On 2026-11-26, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: >> Anyway, I took a peek at V6, and found this gem in the find(1) man >> page: >> >> BUGS >> Syntax should be reconciled with _if_. > > How was that supposed to work, exactly? “if” is a shell builtin, In V6 it wasn't. https://man.freebsd.org/cgi/man.cgi?query=if&manpath=Unix+6th+Edition This was before the Bourne shell introduced ALGOL-style flow control to the shell. The V6 sh(1) had to make do with if(1) and goto(1), both implemented as external commands. Yes, external goto. But even in the Bourne world, _if_ just runs a command and acts on the exit code. test(1) and its alias [ have been implemented as external commands, and even when they are builtins, they still obey the syntactic restrictions of an external command. -- Christian "naddy" Weisgerber naddy@mips.inka.de
Re: The road not taken
Author: Lawrence D’Oliveiro
Date: Fri, 27 Nov 2026 00:36
Date: Fri, 27 Nov 2026 00:36
35 lines
2727 bytes
2727 bytes
On Fri, 27 Nov 2026 00:15:20 -0000 (UTC), Christian Weisgerber wrote: > On 2026-11-26, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > >>> Anyway, I took a peek at V6, and found this gem in the find(1) man >>> page: >>> >>> BUGS >>> Syntax should be reconciled with _if_. >> >> How was that supposed to work, exactly? “if” is a shell builtin, > > In V6 it wasn't. > https://man.freebsd.org/cgi/man.cgi?query=if&manpath=Unix+6th+Edition > > This was before the Bourne shell introduced ALGOL-style flow control > to the shell. The V6 sh(1) had to make do with if(1) and goto(1), > both implemented as external commands. Yes, external goto. So, the “road not taken” was really keeping them as external commands. The only reason this was changed was that the old approach was just too clunky for words. Would you like to revive that idea in a shell now? > But even in the Bourne world, _if_ just runs a command and acts on > the exit code. test(1) and its alias [ have been implemented as > external commands, and even when they are builtins, they still obey > the syntactic restrictions of an external command. See the separation of functions here: “if” just meant “take action depending on exit code”. “test”/“[” then became the mechanism for “compute an arbitrary conditional expression and return an exit code accordingly”, dovetailing nicely into the role of “if”. The old “do one thing, and do it well” motif, yet again ...
Re: The road not taken
Author: Christian Weisgerber
Date: Fri, 27 Nov 2026 12:26
Date: Fri, 27 Nov 2026 12:26
14 lines
1363 bytes
1363 bytes
On 2026-11-27, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: >>>> Anyway, I took a peek at V6, and found this gem in the find(1) man >>>> page: >>>> >>>> Syntax should be reconciled with _if_. > > So, the “road not taken” was really keeping them as external commands. Their operators weren't unified. if(1), later test(1) -r/-w versus find(1) -perm, etc. -- Christian "naddy" Weisgerber naddy@mips.inka.de
Re: The road not taken
Author: Lawrence D’Oliveiro
Date: Fri, 27 Nov 2026 20:57
Date: Fri, 27 Nov 2026 20:57
19 lines
1912 bytes
1912 bytes
On Fri, 27 Nov 2026 12:26:28 -0000 (UTC), Christian Weisgerber wrote: > On 2026-11-27, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > >>>>> Anyway, I took a peek at V6, and found this gem in the find(1) >>>>> man page: >>>>> >>>>> Syntax should be reconciled with _if_. >> >> So, the “road not taken” was really keeping them as external >> commands. > > Their operators weren't unified. if(1), later test(1) -r/-w versus > find(1) -perm, etc. Or you just use test(1) in conjunction with stat(1) <https://manpages.debian.org/stat(1)>. The old “do one thing, and do it well” motif, yet again ...
Re: The road not taken
Author: Dan Cross
Date: Fri, 27 Nov 2026 21:42
Date: Fri, 27 Nov 2026 21:42
34 lines
2323 bytes
2323 bytes
In article <slrn11gitnk.13qg.naddy@lorvorc.mips.inka.de>, Christian Weisgerber <naddy@mips.inka.de> wrote: >On 2026-11-27, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > >>>>> Anyway, I took a peek at V6, and found this gem in the find(1) man >>>>> page: >>>>> >>>>> Syntax should be reconciled with _if_. >> >> So, the “road not taken” was really keeping them as external commands. > >Their operators weren't unified. if(1), later test(1) -r/-w versus >find(1) -perm, etc. Years ago, on Plan 9 (which does not have a `find` command), I had the epiphany that `find` was really just a series of filters with one addition: an `or` operator. I wrote something called, `sor`, for "stream or", that took a series of "tests" as command line arguments and applied each in turn to a series of strings it read from stdin; it was assumed that each string named a file, and the tests would probe characteristics of those files. If any test succeeded, it emitted the string, otherwise it didn't. I wrote another little program called `walk` that just generated a list of file names rooted at some set of directories (I think I added a `-d` option to limit depth). Between `walk`, `sor`, the shell, and the usual complement of unix-y filters, I could do pretty much whatever `find` could do. It wasn't super fast, but it was a fun little exercise. - Dan C.
Re: The road not taken
Author: Janis Papanagnou
Date: Fri, 27 Nov 2026 22:40
Date: Fri, 27 Nov 2026 22:40
30 lines
2616 bytes
2616 bytes
On 2026-11-27 22:42, Dan Cross wrote:
>
> Years ago, on Plan 9 (which does not have a `find` command), I
> had the epiphany that `find` was really just a series of filters
> with one addition: an `or` operator. I wrote something called,
> `sor`, for "stream or", that took a series of "tests" as command
> line arguments and applied each in turn to a series of strings
> it read from stdin; it was assumed that each string named a
> file, and the tests would probe characteristics of those files.
> If any test succeeded, it emitted the string, otherwise it
> didn't.
>
> I wrote another little program called `walk` that just generated
> a list of file names rooted at some set of directories (I think
> I added a `-d` option to limit depth). Between `walk`, `sor`,
> the shell, and the usual complement of unix-y filters, I could
> do pretty much whatever `find` could do.
>
> It wasn't super fast, but it was a fun little exercise.
The advantage of Unix philosophy to comparably simply build ones
own tools. :-)
Have you noticed (and probably tried?) the 'tw' ("tree-walk") tool
from AT&T's AST package? - I'd be interested to hear from users of
'tw' what they think about it from their practical experience with
it.
Janis
Re: The road not taken
Author: Dan Cross
Date: Sun, 29 Nov 2026 23:13
Date: Sun, 29 Nov 2026 23:13
43 lines
2668 bytes
2668 bytes
In article <11ed0s1$1c0gl$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>On 2026-11-27 22:42, Dan Cross wrote:
>>
>> Years ago, on Plan 9 (which does not have a `find` command), I
>> had the epiphany that `find` was really just a series of filters
>> with one addition: an `or` operator. I wrote something called,
>> `sor`, for "stream or", that took a series of "tests" as command
>> line arguments and applied each in turn to a series of strings
>> it read from stdin; it was assumed that each string named a
>> file, and the tests would probe characteristics of those files.
>> If any test succeeded, it emitted the string, otherwise it
>> didn't.
>>
>> I wrote another little program called `walk` that just generated
>> a list of file names rooted at some set of directories (I think
>> I added a `-d` option to limit depth). Between `walk`, `sor`,
>> the shell, and the usual complement of unix-y filters, I could
>> do pretty much whatever `find` could do.
>>
>> It wasn't super fast, but it was a fun little exercise.
>
>The advantage of Unix philosophy to comparably simply build ones
>own tools. :-)
>
>Have you noticed (and probably tried?) the 'tw' ("tree-walk") tool
>from AT&T's AST package? - I'd be interested to hear from users of
>'tw' what they think about it from their practical experience with
>it.
Hmm, I don't think I have. In fact, I'm fairly certain I'd
never heard of it before; at least, it didn't make an
impression.
Looking at it now, or at least the troff source for a blurb
about it, it seems fairly un-Unixy to me; it's more like a DSL
for walking directory hierarchies:
https://github.com/att/ast/blob/master/src/cmd/tw/PROMO.mm
- Dan C.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads