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?
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.
On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
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?
On Tue, 05 Apr 2022 18:01:18 -0700, hongy...@gmail.com wrote:And, what does $1 expand to?
On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)[snip]
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
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?
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:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
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?
On Wednesday, April 6, 2022 at 9:01:37 PM UTC+8, Lew Pitcher wrote:any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
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:And, what does $1 expand to?
On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
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?
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
On Wed, 06 Apr 2022 06:17:40 -0700, hongy...@gmail.com wrote:without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
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:And, what does $1 expand to?
On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)[snip]
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
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?
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
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
On Wednesday, April 6, 2022 at 10:59:27 PM UTC+8, Lew Pitcher wrote:without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
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:And, what does $1 expand to?
On Tuesday, April 5, 2022 at 11:09:27 PM UTC+8, Lew Pitcher wrote:[snip]
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:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)[snip]
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
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?
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
[snip]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
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, IWhat do they mean? Well, on the face of it, they mean that
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?
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:
Even, if a "-b" were part of the further parameters, it would notbe interpreted by "dirname" as an option "b" because of the option
That code snippet is not the cause of the error messages.
On Wednesday, April 6, 2022 at 10:59:27 PM UTC+8, Lew Pitcher wrote:without any argument, the ${BASH_SOURCE[0]} will be used to gather path/script name related information of the library script itself.
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:And, what does $1 expand to?
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:[snip]
Today, when I tried to connect to my computer using SSH, I noticed the following strange information after logging in:What do they mean? Well, on the face of it, they mean that
```
$ 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?
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:
```
scriptdir_realpath=$(cd -P -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd -P)[snip]
script_realdirname=$(dirname -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_realname=$(basename -- "$(realpath -e -- "${1:-${BASH_SOURCE[0]}}")")
script_dirname=$(cd -- "$(dirname -- "${1:-${BASH_SOURCE[0]}}")" && pwd)[snip]
script_name=$(basename -- "${1:-${BASH_SOURCE[0]}}")
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?
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
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),See the following:
1) what does ${BASH_SOURCE[0]} expand to?
2) what does $1 expand to
$ 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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 16:08:38 |
Calls: | 9,826 |
Calls today: | 5 |
Files: | 13,761 |
Messages: | 6,191,145 |