Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Never be led astray onto the path of virtue.


comp / comp.unix.shell / Re: Which shell and how to get started handling arguments

SubjectAuthor
o Re: Which shell and how to get started handling argumentsLawrence D'Oliveiro

1
Subject: Re: Which shell and how to get started handling arguments
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 15 Apr 2024 22:20 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Which shell and how to get started handling arguments
Date: Mon, 15 Apr 2024 22:20:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <uvk97i$h2pg$4@dont-email.me>
References: <uvj65n$9aep$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Apr 2024 00:20:34 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7122d47f46672ef7a70e2ca241d20ff2";
logging-data="559920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18C1lgdmr5oAiUweNhGYlsS"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:dHmfnmZiISLlfGCQLZnZ0TmcX8o=
View all headers

On Mon, 15 Apr 2024 13:22:14 +0100, James Harris wrote:

> I am thinking to write in /the language of/ the Bourne shell, if
> feasible, so that it could be run by either the Bourne shell or Bash,
> etc? (Ideally, the shebang line would be #!/bin/sh.)

There is such a thing as a standardized “POSIX shell”. On Debian, for
example, /bin/sh will launch Dash, which is a minimal POSIX-compliant
shell.

It’s certainly a safe, boring choice. ;)

> Or is Bash now so universal that there's no point any longer in writing
> for anything else?

This is where we get into “Unix®” the trade mark, versus “Unix” as an
informal description of a collection of traditional OS behaviour.

I say this because the only currently “Unix®” trade mark licensee still
seeing any significant use is Apple’s macOS, and that does not offer
Bash--at least, not any reasonably recent version. This is for ideological
reasons or something.

So if you are targeting “Unix” in the latter sense, then Bash is quite
widespread, yes.

> I read up on getopts but from tests it seems to require that switches
> precede arguments rather than allowing them to be specified after, so
> that doesn't seem very good, either.

One reason for that convention is that it is possible for file/directory
names to begin with “-”. To minimize the confusion this causes, there is a
an additional common convention among command-line tools that a plain “--”
option means “don’t look for any more options after this”. That is to say,
treat the remaining items as file names (or whatever else the program does
with them), even if they begin with “-”.

1

rocksolid light 0.9.8
clearnet tor