Re: Fwd: Re: interactive shell detection in shrc

RVP <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
On Wed, 25 Sep 2024, Robert Elz wrote:

> In NetBSD's sh you can actually do
>
> 	''() { echo nothing; }
>
> (where the function body can be anything of course), then the empty-string
> command (as distinct from absent command) does exist, and works, but I would
> not recommend this to anyone, it isn't likely to work elsewhere.
>

This is _very_ surprising; esp. when /bin/sh doesn't allow chars. like `/' and
`.' in the function name.

Can't see a use for this--except to suppress an error message in one inst.:

```
$ ''() false
[...]
$ unset foo
$ if "$foo"; then echo set; else echo unset; fi
```

or, to create (mildly) obfuscated fork-bombs:

```
''(){ ''|''&};''
```

-RVP
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.