Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The identical is equal to itself, since it is different." -- Franco Spisani


devel / comp.unix.shell / Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

SubjectAuthor
* readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.hongy...@gmail.com
`* Re: readlink: invalid option -- 'b' and dirname: invalid option --Lew Pitcher
 `* Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.hongy...@gmail.com
  +* Re: readlink: invalid option -- 'b' and dirname: invalid option --Lew Pitcher
  |`* Re: readlink: invalid option -- 'b' and dirname: invalid option --Lew Pitcher
  | `* Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.hongy...@gmail.com
  |  `* Re: readlink: invalid option -- 'b' and dirname: invalid option --Lew Pitcher
  |   `* Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.hongy...@gmail.com
  |    +- Re: readlink: invalid option -- 'b' and dirname: invalid option --Lew Pitcher
  |    `- Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.hongy...@gmail.com
  `- Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.Helmut Waitzmann

1
readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5208&group=comp.unix.shell#5208

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:59d4:0:b0:2e1:f86d:b38c with SMTP id f20-20020ac859d4000000b002e1f86db38cmr3201150qtf.285.1649169427613;
Tue, 05 Apr 2022 07:37:07 -0700 (PDT)
X-Received: by 2002:a05:620a:4402:b0:67d:1e5d:4899 with SMTP id
v2-20020a05620a440200b0067d1e5d4899mr2415548qkp.736.1649169427436; Tue, 05
Apr 2022 07:37:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 5 Apr 2022 07:37:07 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
Subject: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 05 Apr 2022 14:37:07 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: hongy...@gmail.com - Tue, 5 Apr 2022 14:37 UTC

Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:

```
$ ssh werner@localhost
[...]
dirname: invalid option -- 'b'
Try 'dirname --help' for more information.
readlink: invalid option -- 'b'
Try 'readlink --help' for more information.
```

What do they mean, and what triggered them?

Regards,
HZ

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<t2hm31$d5u$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5209&group=comp.unix.shell#5209

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option --
'b'.
Date: Tue, 5 Apr 2022 15:09:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <t2hm31$d5u$1@dont-email.me>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 5 Apr 2022 15:09:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4c6e5a35ce5052436f409c585d124767";
logging-data="13502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197IxoCwGw2LW5p6S4QIWObsoCcHT0ur40="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:PGo2KQSjMTSf0qRYk0b9nDXwgpU=
 by: Lew Pitcher - Tue, 5 Apr 2022 15:09 UTC

On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:

> Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
>
> ```
> $ ssh werner@localhost
> [...]
> dirname: invalid option -- 'b'
> Try 'dirname --help' for more information.
> readlink: invalid option -- 'b'
> Try 'readlink --help' for more information.
> ```
>
> What do they mean, and what triggered them?

What do they mean? Well, on the face of it, they mean that
neither dirname(1) nor readlink(1) take a 'b' option.

As for what triggered these error messages, your guess
is as good as ours. Most likely, you have some poorly
formed commands in the various shell scripts invoked
when you establish an SSH connection and login.

Look for dirname and readlink in those scripts, and ensure
that the arguments passed to those commands properly
resolve to syntatically correct commands. Specifically,
be suspicious of any substitution variables, as they may
not have the values you expect.

HTH
--
Lew Pitcher
"In Skills, We Trust"

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5213&group=comp.unix.shell#5213

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a0c:9a8a:0:b0:443:cfc9:5dae with SMTP id y10-20020a0c9a8a000000b00443cfc95daemr5276750qvd.94.1649206879301;
Tue, 05 Apr 2022 18:01:19 -0700 (PDT)
X-Received: by 2002:a05:622a:11cb:b0:2e1:a301:2d1d with SMTP id
n11-20020a05622a11cb00b002e1a3012d1dmr5491887qtk.145.1649206879142; Tue, 05
Apr 2022 18:01:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 5 Apr 2022 18:01:18 -0700 (PDT)
In-Reply-To: <t2hm31$d5u$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com> <t2hm31$d5u$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 06 Apr 2022 01:01:19 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 64
 by: hongy...@gmail.com - Wed, 6 Apr 2022 01:01 UTC

On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>
> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
> >
> > ```
> > $ ssh werner@localhost
> > [...]
> > dirname: invalid option -- 'b'
> > Try 'dirname --help' for more information.
> > readlink: invalid option -- 'b'
> > Try 'readlink --help' for more information.
> > ```
> >
> > What do they mean, and what triggered them?
> What do they mean? Well, on the face of it, they mean that
> neither dirname(1) nor readlink(1) take a 'b' option.
>
> As for what triggered these error messages, your guess
> is as good as ours. Most likely, you have some poorly
> formed commands in the various shell scripts invoked
> when you establish an SSH connection and login.
>
> Look for dirname and readlink in those scripts, and ensure
> that the arguments passed to those commands properly
> resolve to syntatically correct commands. Specifically,
> be suspicious of any substitution variables, as they may
> not have the values you expect.

The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:

```
unset scriptdir_realpath
unset script_realdirname script_realname
unset script_realbasename script_realextname
unset script_realpath pkg_realpath

scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)

script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")

script_realbasename=${script_realname%.*}
script_realextname=${script_realname##*.}

script_realpath=$script_realdirname/$script_realname
pkg_realpath=${script_realpath%.*}

unset script_dirname script_name
unset script_basename script_extname
unset script_path

script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")

script_basename=${script_name%.*}
script_extname=${script_name##*.}

script_path=$script_dirname/$script_name
```

Is my usage reasonable in the above code snippet?

Regards,
HZ

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<t2k2ti$1va$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5216&group=comp.unix.shell#5216

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option --
'b'.
Date: Wed, 6 Apr 2022 13:00:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <t2k2ti$1va$1@dont-email.me>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me>
<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Apr 2022 13:00:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="26836ebd76fbc1bcc0f6d36bb03989e1";
logging-data="2026"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dLUtXEou4V7xq56r6C/KEhIXCuVfwUmU="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:NV+9Gopex4zrmGOi7qxhMFOJGWA=
 by: Lew Pitcher - Wed, 6 Apr 2022 13:00 UTC

On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:

> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>>
>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
>> >
>> > ```
>> > $ ssh werner@localhost
>> > [...]
>> > dirname: invalid option -- 'b'
>> > Try 'dirname --help' for more information.
>> > readlink: invalid option -- 'b'
>> > Try 'readlink --help' for more information.
>> > ```
>> >
>> > What do they mean, and what triggered them?
>> What do they mean? Well, on the face of it, they mean that
>> neither dirname(1) nor readlink(1) take a 'b' option.
>>
>> As for what triggered these error messages, your guess
>> is as good as ours. Most likely, you have some poorly
>> formed commands in the various shell scripts invoked
>> when you establish an SSH connection and login.
>>
>> Look for dirname and readlink in those scripts, and ensure
>> that the arguments passed to those commands properly
>> resolve to syntatically correct commands. Specifically,
>> be suspicious of any substitution variables, as they may
>> not have the values you expect.
>
> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
>
> ```
[snip]
> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
>
> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
[snip]
> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
[snip]
> Is my usage reasonable in the above code snippet?

It depends.

What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?

--
Lew Pitcher
"In Skills, We Trust"

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<t2k2vb$1va$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5217&group=comp.unix.shell#5217

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option --
'b'.
Date: Wed, 6 Apr 2022 13:01:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <t2k2vb$1va$2@dont-email.me>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me>
<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Apr 2022 13:01:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="26836ebd76fbc1bcc0f6d36bb03989e1";
logging-data="2026"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fCOspsWyfiL9ocq4GlIpfJdxfJO7+yHY="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:DpeCFr5pbVGL9rHXjnvoTdef0ck=
 by: Lew Pitcher - Wed, 6 Apr 2022 13:01 UTC

On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:

> On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
>
>> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
>>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>>>
>>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
>>> >
>>> > ```
>>> > $ ssh werner@localhost
>>> > [...]
>>> > dirname: invalid option -- 'b'
>>> > Try 'dirname --help' for more information.
>>> > readlink: invalid option -- 'b'
>>> > Try 'readlink --help' for more information.
>>> > ```
>>> >
>>> > What do they mean, and what triggered them?
>>> What do they mean? Well, on the face of it, they mean that
>>> neither dirname(1) nor readlink(1) take a 'b' option.
>>>
>>> As for what triggered these error messages, your guess
>>> is as good as ours. Most likely, you have some poorly
>>> formed commands in the various shell scripts invoked
>>> when you establish an SSH connection and login.
>>>
>>> Look for dirname and readlink in those scripts, and ensure
>>> that the arguments passed to those commands properly
>>> resolve to syntatically correct commands. Specifically,
>>> be suspicious of any substitution variables, as they may
>>> not have the values you expect.
>>
>> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
>>
>> ```
> [snip]
>> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
>>
>> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
>> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> [snip]
>> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
>> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
> [snip]
>> Is my usage reasonable in the above code snippet?
>
> It depends.
>
> What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
And, what does $1 expand to?

--
Lew Pitcher
"In Skills, We Trust"

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5218&group=comp.unix.shell#5218

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:5bc2:0:b0:443:901b:39a with SMTP id t2-20020ad45bc2000000b00443901b039amr7170703qvt.78.1649251060925;
Wed, 06 Apr 2022 06:17:40 -0700 (PDT)
X-Received: by 2002:a05:620a:17ac:b0:699:bf84:5609 with SMTP id
ay44-20020a05620a17ac00b00699bf845609mr5639309qkb.375.1649251060726; Wed, 06
Apr 2022 06:17:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 6 Apr 2022 06:17:40 -0700 (PDT)
In-Reply-To: <t2k2vb$1va$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me> <0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me> <t2k2vb$1va$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 06 Apr 2022 13:17:40 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 69
 by: hongy...@gmail.com - Wed, 6 Apr 2022 13:17 UTC

On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:
> On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:
>
> > On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
> >
> >> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
> >>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
> >>>
> >>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
> >>> >
> >>> > ```
> >>> > $ ssh werner@localhost
> >>> > [...]
> >>> > dirname: invalid option -- 'b'
> >>> > Try 'dirname --help' for more information.
> >>> > readlink: invalid option -- 'b'
> >>> > Try 'readlink --help' for more information.
> >>> > ```
> >>> >
> >>> > What do they mean, and what triggered them?
> >>> What do they mean? Well, on the face of it, they mean that
> >>> neither dirname(1) nor readlink(1) take a 'b' option.
> >>>
> >>> As for what triggered these error messages, your guess
> >>> is as good as ours. Most likely, you have some poorly
> >>> formed commands in the various shell scripts invoked
> >>> when you establish an SSH connection and login.
> >>>
> >>> Look for dirname and readlink in those scripts, and ensure
> >>> that the arguments passed to those commands properly
> >>> resolve to syntatically correct commands. Specifically,
> >>> be suspicious of any substitution variables, as they may
> >>> not have the values you expect.
> >>
> >> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
> >>
> >> ```
> > [snip]
> >> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
> >>
> >> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> >> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> > [snip]
> >> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
> >> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
> > [snip]
> >> Is my usage reasonable in the above code snippet?
> >
> > It depends.
> >
> > What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
> And, what does $1 expand to?

I use it as a bash based library script, which, when sourced from another bash script with this script's name as the argument, i.e., $1, will give some path/script name related information of the invoking script. OTOH, if the script is sourced without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.

Regards,
HZ

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<t2k9sa$aj1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5219&group=comp.unix.shell#5219

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option --
'b'.
Date: Wed, 6 Apr 2022 14:59:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <t2k9sa$aj1$1@dont-email.me>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me>
<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me> <t2k2vb$1va$2@dont-email.me>
<86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 6 Apr 2022 14:59:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="26836ebd76fbc1bcc0f6d36bb03989e1";
logging-data="10849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BpkxuamJNP5xRnt9qGqezPfqlOWZPPEQ="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:wG9wBFtzerZE1ZIeoQ9Tgk5JPaY=
 by: Lew Pitcher - Wed, 6 Apr 2022 14:59 UTC

On Wed, 06 Apr 2022 06:17:40 -0700, hongy...@gmail.com wrote:

> On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:
>> On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:
>>
>> > On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
>> >
>> >> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
>> >>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>> >>>
>> >>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
>> >>> >
>> >>> > ```
>> >>> > $ ssh werner@localhost
>> >>> > [...]
>> >>> > dirname: invalid option -- 'b'
>> >>> > Try 'dirname --help' for more information.
>> >>> > readlink: invalid option -- 'b'
>> >>> > Try 'readlink --help' for more information.
>> >>> > ```
>> >>> >
>> >>> > What do they mean, and what triggered them?
>> >>> What do they mean? Well, on the face of it, they mean that
>> >>> neither dirname(1) nor readlink(1) take a 'b' option.
>> >>>
>> >>> As for what triggered these error messages, your guess
>> >>> is as good as ours. Most likely, you have some poorly
>> >>> formed commands in the various shell scripts invoked
>> >>> when you establish an SSH connection and login.
>> >>>
>> >>> Look for dirname and readlink in those scripts, and ensure
>> >>> that the arguments passed to those commands properly
>> >>> resolve to syntatically correct commands. Specifically,
>> >>> be suspicious of any substitution variables, as they may
>> >>> not have the values you expect.
>> >>
>> >> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
>> >>
>> >> ```
>> > [snip]
>> >> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
>> >>
>> >> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
>> >> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
>> > [snip]
>> >> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
>> >> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
>> > [snip]
>> >> Is my usage reasonable in the above code snippet?
>> >
>> > It depends.
>> >
>> > What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
>> And, what does $1 expand to?
>
> I use it as a bash based library script, which, when sourced from another bash script with this script's name as the argument, i.e., $1, will give some path/script name related information of the invoking script. OTOH, if the script is sourced without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.

And now we know what the snippet is supposed to do.

As for your failure mode, you still need to answer the questions
(specifically, when you encounter the error messages),
1) what does ${BASH_SOURCE[0]} expand to?
2) what does $1 expand to

--
Lew Pitcher
"In Skills, We Trust"

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<742adb74-fdcf-440b-a444-20b3bbec7824n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5221&group=comp.unix.shell#5221

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:5a95:0:b0:2e2:e4f:63c with SMTP id c21-20020ac85a95000000b002e20e4f063cmr9898844qtc.537.1649293243526;
Wed, 06 Apr 2022 18:00:43 -0700 (PDT)
X-Received: by 2002:a05:620a:20c2:b0:67d:2fb1:d358 with SMTP id
f2-20020a05620a20c200b0067d2fb1d358mr7726087qka.55.1649293243348; Wed, 06 Apr
2022 18:00:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 6 Apr 2022 18:00:43 -0700 (PDT)
In-Reply-To: <t2k9sa$aj1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me> <0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me> <t2k2vb$1va$2@dont-email.me> <86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>
<t2k9sa$aj1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <742adb74-fdcf-440b-a444-20b3bbec7824n@googlegroups.com>
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Thu, 07 Apr 2022 01:00:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 136
 by: hongy...@gmail.com - Thu, 7 Apr 2022 01:00 UTC

On Wednesday, April 6, 2022 at 10:59:27 PM UTC+8, Lew Pitcher wrote:
> On Wed, 06 Apr 2022 06:17:40 -0700, hongy...@gmail.com wrote:
>
> > On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:
> >> On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:
> >>
> >> > On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
> >> >
> >> >> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
> >> >>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
> >> >>>
> >> >>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
> >> >>> >
> >> >>> > ```
> >> >>> > $ ssh werner@localhost
> >> >>> > [...]
> >> >>> > dirname: invalid option -- 'b'
> >> >>> > Try 'dirname --help' for more information.
> >> >>> > readlink: invalid option -- 'b'
> >> >>> > Try 'readlink --help' for more information.
> >> >>> > ```
> >> >>> >
> >> >>> > What do they mean, and what triggered them?
> >> >>> What do they mean? Well, on the face of it, they mean that
> >> >>> neither dirname(1) nor readlink(1) take a 'b' option.
> >> >>>
> >> >>> As for what triggered these error messages, your guess
> >> >>> is as good as ours. Most likely, you have some poorly
> >> >>> formed commands in the various shell scripts invoked
> >> >>> when you establish an SSH connection and login.
> >> >>>
> >> >>> Look for dirname and readlink in those scripts, and ensure
> >> >>> that the arguments passed to those commands properly
> >> >>> resolve to syntatically correct commands. Specifically,
> >> >>> be suspicious of any substitution variables, as they may
> >> >>> not have the values you expect.
> >> >>
> >> >> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
> >> >>
> >> >> ```
> >> > [snip]
> >> >> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
> >> >>
> >> >> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> >> >> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> >> > [snip]
> >> >> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
> >> >> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
> >> > [snip]
> >> >> Is my usage reasonable in the above code snippet?
> >> >
> >> > It depends.
> >> >
> >> > What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
> >> And, what does $1 expand to?
> >
> > I use it as a bash based library script, which, when sourced from another bash script with this script's name as the argument, i.e., $1, will give some path/script name related information of the invoking script. OTOH, if the script is sourced without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
> And now we know what the snippet is supposed to do.
>
> As for your failure mode, you still need to answer the questions
> (specifically, when you encounter the error messages),
> 1) what does ${BASH_SOURCE[0]} expand to?
> 2) what does $1 expand to

See the following:

$ cat bash-lib.sh
unset scriptdir_realpath
unset script_realdirname script_realname
unset script_realbasename script_realextname
unset script_realpath pkg_realpath

scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)

script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")

script_realbasename=${script_realname%.*}
script_realextname=${script_realname##*.}

script_realpath=$script_realdirname/$script_realname
pkg_realpath=${script_realpath%.*}

unset script_dirname script_name
unset script_basename script_extname
unset script_path

script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")

script_basename=${script_name%.*}
script_extname=${script_name##*.}

script_path=$script_dirname/$script_name

echo ''
echo '${BASH_SOURCE[0]}=' ${BASH_SOURCE[0]}
echo '$1=' $1

$ cat test-bash-lib.sh
.. bash-lib.sh

echo ''
echo '${BASH_SOURCE[0]}=' ${BASH_SOURCE[0]}
echo '$1=' $1

$ . bash-lib.sh

${BASH_SOURCE[0]}= bash-lib.sh
$1
$ . test-bash-lib.sh

${BASH_SOURCE[0]}= bash-lib.sh
$1
${BASH_SOURCE[0]}= test-bash-lib.sh
$1
Regards,
HZ

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<t2n238$58h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5224&group=comp.unix.shell#5224

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option --
'b'.
Date: Thu, 7 Apr 2022 16:04:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 114
Message-ID: <t2n238$58h$1@dont-email.me>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me>
<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me> <t2k2vb$1va$2@dont-email.me>
<86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>
<t2k9sa$aj1$1@dont-email.me>
<742adb74-fdcf-440b-a444-20b3bbec7824n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 7 Apr 2022 16:04:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="15cd828b5cb23d22c52753fed8361fbb";
logging-data="5393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IDwc06S9MGNaNozxq2lPSWZxqKcOonZs="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:xFmgJ7P2pvrhYjWEzpuJyThtFME=
 by: Lew Pitcher - Thu, 7 Apr 2022 16:04 UTC

On Wed, 06 Apr 2022 18:00:43 -0700, hongy...@gmail.com wrote:

> On Wednesday, April 6, 2022 at 10:59:27 PM UTC+8, Lew Pitcher wrote:
>> On Wed, 06 Apr 2022 06:17:40 -0700, hongy...@gmail.com wrote:
>>
>> > On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:
>> >> On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:
>> >>
>> >> > On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
>> >> >
>> >> >> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
>> >> >>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>> >> >>>
>> >> >>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
>> >> >>> >
>> >> >>> > ```
>> >> >>> > $ ssh werner@localhost
>> >> >>> > [...]
>> >> >>> > dirname: invalid option -- 'b'
>> >> >>> > Try 'dirname --help' for more information.
>> >> >>> > readlink: invalid option -- 'b'
>> >> >>> > Try 'readlink --help' for more information.
>> >> >>> > ```
>> >> >>> >
>> >> >>> > What do they mean, and what triggered them?
>> >> >>> What do they mean? Well, on the face of it, they mean that
>> >> >>> neither dirname(1) nor readlink(1) take a 'b' option.
>> >> >>>
>> >> >>> As for what triggered these error messages, your guess
>> >> >>> is as good as ours. Most likely, you have some poorly
>> >> >>> formed commands in the various shell scripts invoked
>> >> >>> when you establish an SSH connection and login.
>> >> >>>
>> >> >>> Look for dirname and readlink in those scripts, and ensure
>> >> >>> that the arguments passed to those commands properly
>> >> >>> resolve to syntatically correct commands. Specifically,
>> >> >>> be suspicious of any substitution variables, as they may
>> >> >>> not have the values you expect.
>> >> >>
>> >> >> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
>> >> >>
>> >> >> ```
>> >> > [snip]
>> >> >> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
>> >> >>
>> >> >> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
>> >> >> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
>> >> > [snip]
>> >> >> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
>> >> >> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
>> >> > [snip]
>> >> >> Is my usage reasonable in the above code snippet?
>> >> >
>> >> > It depends.
>> >> >
>> >> > What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
>> >> And, what does $1 expand to?
>> >
>> > I use it as a bash based library script, which, when sourced from another bash script with this script's name as the argument, i.e., $1, will give some path/script name related information of the invoking script. OTOH, if the script is sourced without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
>> And now we know what the snippet is supposed to do.
>>
>> As for your failure mode, you still need to answer the questions
>> (specifically, when you encounter the error messages),
>> 1) what does ${BASH_SOURCE[0]} expand to?
>> 2) what does $1 expand to
>
> See the following:
>
> $ cat bash-lib.sh
[snip]

That tells me nothing that I can't see from your previous snippet.

So, let's recap.

You have a script or scripts, buried somewhere within the sum total
of scripts that ssh executes on your behalf when you log in to a
remote system, that generate specific error messages. You wish to
debug and rectify these error messages. The error messages are:
dirname: invalid option -- 'b'
Try 'dirname --help' for more information.
readlink: invalid option -- 'b'
Try 'readlink --help' for more information.

First off, the error messages are mostly self-explanatory. Somewhere
in your scripts, you invoke dirname(1) with the "-b" option, and
elsewhere, you invoke readlink(1), again with the "-b" option. Neither
dirname(1) nor readlink(1) /have/ a "-b" option, and tell you so.

So, you have to determine
1) where the offending dirname(1) is,
2) how that dirname(1) gets an errant "-b" option,
3) where the offending readlink(1) is, and
4) how that readlink(1) gets an errant "-b" option

Then, you have to change things so that neither the
dirname(1) nor the readlink(1) get the bad "-b" option.

By implication, you have isolated the offending dirname(1) and
readlink(1) invocations to a specific code snippet, which you
posted here. These invocations depend on the /specific values/
of two parameters: $1 and ${BASH_SOURCE[0]}. The values of these
two parameters, on login via ssh, will tell you if you have
located the offending code snippet. At least one of these values
will contain a "-b", the offending option passed to dirname(1)
and readlink(1).

Find that, and fix it.

HTH
--30--
--
Lew Pitcher
"In Skills, We Trust"

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<83tub4ra7m.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5225&group=comp.unix.shell#5225

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!P7nabxCfwAWWarebWBOvhw.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
Date: Thu, 07 Apr 2022 20:59:25 +0200
Organization: Aioe.org NNTP Server
Message-ID: <83tub4ra7m.fsf@helmutwaitzmann.news.arcor.de>
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me>
<0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="29169"; posting-host="P7nabxCfwAWWarebWBOvhw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:L4+I2gyGqrc9b4F+nRIytwKdiak=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
X-Notice: Filtered by postfilter v. 0.9.2
 by: Helmut Waitzmann - Thu, 7 Apr 2022 18:59 UTC

"hongy...@gmail.com" <hongyi.zhao@gmail.com>:
>On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
>>
>>> Today, when I tried to connect to my computer using SSH, I
>>> noticed the following strange information after logging in:
>>>
>>> ```
>>> $ ssh werner@localhost
>>> [...]
>>> dirname: invalid option -- 'b'
>>> Try 'dirname --help' for more information.
>>> readlink: invalid option -- 'b'
>>> Try 'readlink --help' for more information.
>>> ```
>>>
>>> What do they mean, and what triggered them?
>>>
>> What do they mean? Well, on the face of it, they mean that
>> neither dirname(1) nor readlink(1) take a 'b' option.
>>
>> As for what triggered these error messages, your guess
>> is as good as ours. Most likely, you have some poorly
>> formed commands in the various shell scripts invoked
>> when you establish an SSH connection and login.
>>
>> Look for dirname and readlink in those scripts, and ensure
>> that the arguments passed to those commands properly
>> resolve to syntatically correct commands. Specifically,
>> be suspicious of any substitution variables, as they may
>> not have the values you expect.
>
>The following is some code snippet in one of the various shell
>scripts invoked when I establish an SSH connection and login:
>

[…]

In that code snippet, there is no invocation of "readlink".

Also, in that code snippet, all invocations of "dirname" are of the
form

dirname -- further parameters

=> Even, if a "-b" were part of the further parameters, it would not
be interpreted by "dirname" as an option "b" because of the option
terminator "--".

=> That code snippet is not the cause of the error messages.

Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.

<5824307f-af24-4a23-a7a3-299ed88c4f18n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5226&group=comp.unix.shell#5226

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:2403:b0:680:d004:fb3f with SMTP id d3-20020a05620a240300b00680d004fb3fmr11173528qkn.293.1649383435441;
Thu, 07 Apr 2022 19:03:55 -0700 (PDT)
X-Received: by 2002:a05:620a:4481:b0:67e:c1f2:9bee with SMTP id
x1-20020a05620a448100b0067ec1f29beemr11587436qkp.264.1649383435286; Thu, 07
Apr 2022 19:03:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 7 Apr 2022 19:03:55 -0700 (PDT)
In-Reply-To: <742adb74-fdcf-440b-a444-20b3bbec7824n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <58d9d727-969f-492f-9fc3-4c534d928656n@googlegroups.com>
<t2hm31$d5u$1@dont-email.me> <0506f798-1b19-4c34-8ad5-667e0d0c64c4n@googlegroups.com>
<t2k2ti$1va$1@dont-email.me> <t2k2vb$1va$2@dont-email.me> <86377dab-3c8e-411c-b3c8-d8453491c3cbn@googlegroups.com>
<t2k9sa$aj1$1@dont-email.me> <742adb74-fdcf-440b-a444-20b3bbec7824n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5824307f-af24-4a23-a7a3-299ed88c4f18n@googlegroups.com>
Subject: Re: readlink: invalid option -- 'b' and dirname: invalid option -- 'b'.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 08 Apr 2022 02:03:55 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 154
 by: hongy...@gmail.com - Fri, 8 Apr 2022 02:03 UTC

On Thursday, April 7, 2022 at 9:00:45 AM UTC+8, hongy...@gmail.com wrote:
> On Wednesday, April 6, 2022 at 10:59:27 PM UTC+8, Lew Pitcher wrote:
> > On Wed, 06 Apr 2022 06:17:40 -0700, hongy...@gmail.com wrote:
> >
> > > On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:
> > >> On Wed, 06 Apr 2022 13:00:34 +0000, Lew Pitcher wrote:
> > >>
> > >> > On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:
> > >> >
> > >> >> On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:
> > >> >>> On Tue, 05 Apr 2022 07:37:07 -0700, hongy...@gmail.com wrote:
> > >> >>>
> > >> >>> > Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:
> > >> >>> >
> > >> >>> > ```
> > >> >>> > $ ssh werner@localhost
> > >> >>> > [...]
> > >> >>> > dirname: invalid option -- 'b'
> > >> >>> > Try 'dirname --help' for more information.
> > >> >>> > readlink: invalid option -- 'b'
> > >> >>> > Try 'readlink --help' for more information.
> > >> >>> > ```
> > >> >>> >
> > >> >>> > What do they mean, and what triggered them?
> > >> >>> What do they mean? Well, on the face of it, they mean that
> > >> >>> neither dirname(1) nor readlink(1) take a 'b' option.
> > >> >>>
> > >> >>> As for what triggered these error messages, your guess
> > >> >>> is as good as ours. Most likely, you have some poorly
> > >> >>> formed commands in the various shell scripts invoked
> > >> >>> when you establish an SSH connection and login.
> > >> >>>
> > >> >>> Look for dirname and readlink in those scripts, and ensure
> > >> >>> that the arguments passed to those commands properly
> > >> >>> resolve to syntatically correct commands. Specifically,
> > >> >>> be suspicious of any substitution variables, as they may
> > >> >>> not have the values you expect.
> > >> >>
> > >> >> The following is some code snippet in one of the various shell scripts invoked when I establish an SSH connection and login:
> > >> >>
> > >> >> ```
> > >> > [snip]
> > >> >> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
> > >> >>
> > >> >> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> > >> >> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> > >> > [snip]
> > >> >> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
> > >> >> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
> > >> > [snip]
> > >> >> Is my usage reasonable in the above code snippet?
> > >> >
> > >> > It depends.
> > >> >
> > >> > What is the snipped /supposed/ to do, and what does ${BASH_SOURCE[0]} expand to?
> > >> And, what does $1 expand to?
> > >
> > > I use it as a bash based library script, which, when sourced from another bash script with this script's name as the argument, i.e., $1, will give some path/script name related information of the invoking script. OTOH, if the script is sourced without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
> > And now we know what the snippet is supposed to do.
> >
> > As for your failure mode, you still need to answer the questions
> > (specifically, when you encounter the error messages),
> > 1) what does ${BASH_SOURCE[0]} expand to?
> > 2) what does $1 expand to
> See the following:
>
> $ cat bash-lib.sh
> unset scriptdir_realpath
> unset script_realdirname script_realname
> unset script_realbasename script_realextname
> unset script_realpath pkg_realpath
> scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)
>
> script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
> script_realbasename=${script_realname%.*}
> script_realextname=${script_realname##*.}
>
> script_realpath=$script_realdirname/$script_realname
> pkg_realpath=${script_realpath%.*}
>
> unset script_dirname script_name
> unset script_basename script_extname
> unset script_path
> script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)
> script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
> script_basename=${script_name%.*}
> script_extname=${script_name##*.}
>
> script_path=$script_dirname/$script_name
> echo ''
> echo '${BASH_SOURCE[0]}=' ${BASH_SOURCE[0]}
> echo '$1=' $1
>
> $ cat test-bash-lib.sh
> . bash-lib.sh
>
> echo ''
> echo '${BASH_SOURCE[0]}=' ${BASH_SOURCE[0]}
> echo '$1=' $1

I should have written the following:

$ cat test-bash-lib.sh
.. bash-lib.sh ${BASH_SOURCE[0]}

echo ''
echo '${BASH_SOURCE[0]}=' ${BASH_SOURCE[0]}
echo '$1=' $1


> $ . bash-lib.sh
>
> ${BASH_SOURCE[0]}= bash-lib.sh
> $1=
>
> $ . test-bash-lib.sh
>
> ${BASH_SOURCE[0]}= bash-lib.sh
> $1=
>
> ${BASH_SOURCE[0]}= test-bash-lib.sh
> $1=

And accordingly:

$ . test-bash-lib.sh

${BASH_SOURCE[0]}= bash-lib.sh
$1= test-bash-lib.sh

${BASH_SOURCE[0]}= test-bash-lib.sh
$1
> Regards,
> HZ

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor