Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

If God had a beard, he'd be a UNIX programmer.


devel / comp.unix.shell / Over-Elaborate Shell Scripting

SubjectAuthor
* Over-Elaborate Shell ScriptingLawrence D'Oliveiro
+* Re: Over-Elaborate Shell ScriptingJanis Papanagnou
|`- Re: Over-Elaborate Shell ScriptingLawrence D'Oliveiro
+* Re: Over-Elaborate Shell ScriptingJohanne Fairchild
|`* Re: Over-Elaborate Shell ScriptingGrant Taylor
| `- Re: Over-Elaborate Shell ScriptingJohanne Fairchild
`* Re: Over-Elaborate Shell ScriptingGrant Taylor
 `* Re: Over-Elaborate Shell ScriptingJosef Moellers
  +- Re: Over-Elaborate Shell ScriptingGrant Taylor
  `- Re: Over-Elaborate Shell ScriptingLawrence D'Oliveiro

1
Over-Elaborate Shell Scripting

<utlpro$3fai5$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7721&group=comp.unix.shell#7721

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 05:38:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <utlpro$3fai5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Mar 2024 05:38:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="50afb5c9c454d4fc23edeea8f731b72c";
logging-data="3648069"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19db+vrwTuSUIoC3QnHY7AZ"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:WVPmXM4DmbMpV5nr2GfTn5xebNw=
 by: Lawrence D'Oliv - Sat, 23 Mar 2024 05:38 UTC

When using a computer, laziness is a virtue. This is why we have
command lines, to help automate the boring and repetitive tasks.

This article
<https://arstechnica.com/gadgets/2021/09/command-line-wizardry-part-two-variables-and-loops-in-bash/>
continues the author’s intro to basic command-line concepts. But it
repeats a failing I see all too often in shell scripting: doing complex
parsing of the output of some command, when the command itself offers an
option to produce something closer to the exact output you need.

In this case, he is extracting the names of datasets from the “zfs
list” command. And while I have zero experience with ZFS, I can look at
documentation
<https://docs.oracle.com/cd/E18752_01/html/819-5461/gazsu.html>, and
discover that the command offers the “-o” option where you can select
exactly that information you want it to output. It even has “-H” to
simplify the output format right down, specifically to make it easier
to parse.

Sure, it’s fun to write code. But it can be even more fun to _avoid_
writing code. RTFM helps.

Re: Over-Elaborate Shell Scripting

<utlu7f$3gail$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7722&group=comp.unix.shell#7722

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 07:52:29 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <utlu7f$3gail$1@dont-email.me>
References: <utlpro$3fai5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Mar 2024 06:52:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f757d83ec11571807f0ac7a967c8fdd6";
logging-data="3680853"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cbr2ynufYtfooOLB91Kx+"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:2XcNG11UUmYhsbOi7w83tmXObgg=
In-Reply-To: <utlpro$3fai5$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 23 Mar 2024 06:52 UTC

On 23.03.2024 06:38, Lawrence D'Oliveiro wrote:
> When using a computer, laziness is a virtue. This is why we have
> command lines, to help automate the boring and repetitive tasks.
>
> This article
> <https://arstechnica.com/gadgets/2021/09/command-line-wizardry-part-two-variables-and-loops-in-bash/>

(Not really sophisticated written shell code samples.)

It seems his focus was about "Variables and loops in Bash", though,
not primarily about ZFS output parsing. (He could certainly have
chosen another example and solution.)

> continues the author’s intro to basic command-line concepts. But it
> repeats a failing I see all too often in shell scripting: doing complex
> parsing of the output of some command, when the command itself offers an
> option to produce something closer to the exact output you need.
>
> In this case, he is extracting the names of datasets from the “zfs
> list” command. And while I have zero experience with ZFS, I can look at
> documentation
> <https://docs.oracle.com/cd/E18752_01/html/819-5461/gazsu.html>, and
> discover that the command offers the “-o” option where you can select
> exactly that information you want it to output. It even has “-H” to
> simplify the output format right down, specifically to make it easier
> to parse.
>
> Sure, it’s fun to write code. But it can be even more fun to _avoid_
> writing code. RTFM helps.
>

Yes.

But it also makes sense to remind the tool developers of their duties!

I recall the first sensible tool to follow (or invent?) the option for
output format definition to have been AIX's 'ps' command; that was in
the early 1990's. Since then at times only few tools followed that path.
IMO such an option (where appropriate) should be standard.

It's even worse where the same attribute changes its format, depending
on other conditions, like 'ls' time information depending on file age;
meanwhile there were some also non-standard approaches to handle that
(like GNU's 'ls --full-time', which is certainly not a handy format but
at least provides a consistent output).

Some commands change output format depending on the locale; which may
also be an issue for tools that don't consider that.

Janis

Re: Over-Elaborate Shell Scripting

<utm0km$3gqi2$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7723&group=comp.unix.shell#7723

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 07:33:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <utm0km$3gqi2$1@dont-email.me>
References: <utlpro$3fai5$1@dont-email.me> <utlu7f$3gail$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Mar 2024 07:33:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="50afb5c9c454d4fc23edeea8f731b72c";
logging-data="3697218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ih8vz6Vm+WynDS/uTWPq6"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:T1wBTQ6KgmH2SwghAYUOUJnTppE=
 by: Lawrence D'Oliv - Sat, 23 Mar 2024 07:33 UTC

On Sat, 23 Mar 2024 07:52:29 +0100, Janis Papanagnou wrote:

> But it also makes sense to remind the tool developers of their duties!

Some tools offer the option of JSON output. And there is “jq” for
performing manipulations on such JSON streams
<https://manpages.debian.org/1/jq.en.html>.

Re: Over-Elaborate Shell Scripting

<87frwhthp6.fsf@tudado.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7724&group=comp.unix.shell#7724

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jfairchild@tudado.org (Johanne Fairchild)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 06:34:29 -0300
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87frwhthp6.fsf@tudado.org>
References: <utlpro$3fai5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="384c284007d771387abadbbfc547cb89";
logging-data="3744322"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qvn0yXW/aaDnfPNjt8qUfkSD957OFE+k="
Cancel-Lock: sha1:nCDN1T+pLZa1nqGqjMq+nNZ510w=
sha1:CkgsayrU8f5qqhpr8f1U2RNsMM4=
 by: Johanne Fairchild - Sat, 23 Mar 2024 09:34 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:

> This article
> <https://arstechnica.com/gadgets/2021/09/command-line-wizardry-part-two-variables-and-loops-in-bash/>
> continues the author’s intro to basic command-line concepts. But it
> repeats a failing I see all too often in shell scripting:

Here's another thing I often see in web writers. If they're teaching
you something, there's a high probability they have just learned it---or
so they think they did.

Re: Over-Elaborate Shell Scripting

<utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7725&group=comp.unix.shell#7725

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 13:19:40 -0500
Organization: TNet Consulting
Message-ID: <utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>
References: <utlpro$3fai5$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Mar 2024 18:19:40 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="10915"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <utlpro$3fai5$1@dont-email.me>
 by: Grant Taylor - Sat, 23 Mar 2024 18:19 UTC

On 3/23/24 00:38, Lawrence D'Oliveiro wrote:
> When using a computer, laziness is a virtue. This is why we have
> command lines, to help automate the boring and repetitive tasks.

Yes.

> This article
> <https://arstechnica.com/gadgets/2021/09/command-line-wizardry-part-two-variables-and-loops-in-bash/>
> continues the author’s intro to basic command-line concepts. But it
> repeats a failing I see all too often in shell scripting: doing complex
> parsing of the output of some command, when the command itself offers
> an option to produce something closer to the exact output you need.

Keep in mind that some such authors have been working with a command for
a very long time and that there is chances that the command has evolved
since they started using it.

Once a process has been learned, it is slow to evolve until it no longer
works properly.

> Sure, it’s fun to write code. But it can be even more fun to _avoid_
> writing code. RTFM helps.

I'm the epitome of lazy Unix admin. I try to avoid doing things,
especially repetitive things, if I can. I'd much rather spend some time
streamlining -> automating something if I know that I'm going to end up
doing it many times.

But, sometimes it's also good to go through an exercise. Especially if
some of those exercises are to teach / refresh someone, possibly
yourself, on a concept that they aren't as fresh on as they possibly
want to be.

--
Grant. . . .

Re: Over-Elaborate Shell Scripting

<utn6hg$al3$9@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7726&group=comp.unix.shell#7726

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.quux.org!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 13:20:32 -0500
Organization: TNet Consulting
Message-ID: <utn6hg$al3$9@tncsrv09.home.tnetconsulting.net>
References: <utlpro$3fai5$1@dont-email.me> <87frwhthp6.fsf@tudado.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 23 Mar 2024 18:20:32 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="10915"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <87frwhthp6.fsf@tudado.org>
 by: Grant Taylor - Sat, 23 Mar 2024 18:20 UTC

On 3/23/24 04:34, Johanne Fairchild wrote:
> Here's another thing I often see in web writers. If they're teaching
> you something, there's a high probability they have just learned
> it---or so they think they did.

I don't have any problem with "Hey, look what I just learned!" type
articles.

I do object when such articles are disguised as experts in the subject.

--
Grant. . . .

Re: Over-Elaborate Shell Scripting

<87wmpsk0zy.fsf@tudado.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7727&group=comp.unix.shell#7727

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jfairchild@tudado.org (Johanne Fairchild)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sat, 23 Mar 2024 20:00:01 -0300
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <87wmpsk0zy.fsf@tudado.org>
References: <utlpro$3fai5$1@dont-email.me> <87frwhthp6.fsf@tudado.org>
<utn6hg$al3$9@tncsrv09.home.tnetconsulting.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1f4eb8465f6e03e1696d03a21834eabb";
logging-data="4114935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dIXaTmO6FIVBr+pYRqVU4SsghPDadrA0="
Cancel-Lock: sha1:3bW3NB7ZNhmdQhDYr6PxgluysLM=
sha1:47Q1wlAh+8vbpwvd6fLy+JF7tiQ=
 by: Johanne Fairchild - Sat, 23 Mar 2024 23:00 UTC

Grant Taylor <gtaylor@tnetconsulting.net> writes:

> On 3/23/24 04:34, Johanne Fairchild wrote:
>> Here's another thing I often see in web writers. If they're
>> teaching you something, there's a high probability they have just
>> learned it---or so they think they did.
>
> I don't have any problem with "Hey, look what I just learned!" type
> articles.

On the contrary---we encourage such articles.

> I do object when such articles are disguised as experts in the subject.

Indeed. More often than not (of course), many such bloggers actually
think that they know what's going on. So on average the web is a poor
source of the information.

Re: Over-Elaborate Shell Scripting

<l6b9qkF5volU1@mid.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7728&group=comp.unix.shell#7728

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef.moellers@invalid.invalid (Josef Moellers)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sun, 24 Mar 2024 19:30:44 +0100
Lines: 19
Message-ID: <l6b9qkF5volU1@mid.individual.net>
References: <utlpro$3fai5$1@dont-email.me>
<utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net ENSO/pE+JL8KUgDLhKcmgQDbZ/jOehWRMlvz5AoeUs6jvCXhag
Cancel-Lock: sha1:piBa87/XO533W1oOFlAZnkUUnX0= sha256:oxa5ClIvDyYGOldKyPC5ArCdhe5HxnRfyQXz3S8sSCI=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>
 by: Josef Moellers - Sun, 24 Mar 2024 18:30 UTC

On 23.03.24 19:19, Grant Taylor wrote:
> On 3/23/24 00:38, Lawrence D'Oliveiro wrote:
>> When using a computer, laziness is a virtue. This is why we have
>> command lines, to help automate the boring and repetitive tasks.
>
> Yes.
>
>> This article
>> <https://arstechnica.com/gadgets/2021/09/command-line-wizardry-part-two-variables-and-loops-in-bash/> continues the author’s intro to basic command-line concepts. But it repeats a failing I see all too often in shell scripting: doing complex parsing of the output of some command, when the command itself offers an option to produce something closer to the exact output you need.
>
> Keep in mind that some such authors have been working with a command for
> a very long time and that there is chances that the command has evolved
> since they started using it.

Keep also in mind that MAYBE not all incarnations of a command may have
this feature, so resorting to a generic solution that works on all
versions of the command may be a virtue.

Josef

Re: Over-Elaborate Shell Scripting

<utpsf6$ifg$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7729&group=comp.unix.shell#7729

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.omega.home.tnetconsulting.net!not-for-mail
From: gtaylor@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sun, 24 Mar 2024 13:47:02 -0500
Organization: TNet Consulting
Message-ID: <utpsf6$ifg$1@tncsrv09.home.tnetconsulting.net>
References: <utlpro$3fai5$1@dont-email.me>
<utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>
<l6b9qkF5volU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 24 Mar 2024 18:47:02 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="omega.home.tnetconsulting.net:198.18.1.140";
logging-data="18928"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <l6b9qkF5volU1@mid.individual.net>
 by: Grant Taylor - Sun, 24 Mar 2024 18:47 UTC

On 3/24/24 13:30, Josef Moellers wrote:
> Keep also in mind that MAYBE not all incarnations of a command may have
> this feature, so resorting to a generic solution that works on all
> versions of the command may be a virtue.

Yep.

Keeping (some) scripts portable has virtue.

But not all scripts need to be portable.

Scripts managing systesmd almost certainly won't be used on non-Linux
systems. ;-)

--
Grant. . . .

Re: Over-Elaborate Shell Scripting

<utq6pp$jsuq$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=7730&group=comp.unix.shell#7730

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Over-Elaborate Shell Scripting
Date: Sun, 24 Mar 2024 21:43:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <utq6pp$jsuq$1@dont-email.me>
References: <utlpro$3fai5$1@dont-email.me>
<utn6fs$al3$8@tncsrv09.home.tnetconsulting.net>
<l6b9qkF5volU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 24 Mar 2024 22:43:21 +0100
Injection-Info: dont-email.me; posting-host="1fcc56b8d95a226f6c1eceee7c3d33b8";
logging-data="652250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wTJyNkAb5RPPamYZXfSxF"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:qgy36zufJgBIzamwFY0IIvwVmDg=
 by: Lawrence D'Oliv - Sun, 24 Mar 2024 21:43 UTC

On Sun, 24 Mar 2024 19:30:44 +0100, Josef Moellers wrote:

> ... MAYBE not all incarnations of a command may have
> this feature ...

Except this particular “feature” came from a single vendor, who developed
all the associated tooling as well.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor