Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

IOT trap -- core dumped


devel / comp.unix.shell / why bash in $0 ?

SubjectAuthor
* why bash in $0 ?Popping Mad
+* why bash in $0 ?Felix Palmen
|`* why bash in $0 ?Popping Mad
| +* why bash in $0 ?Keith Thompson
| |`* why bash in $0 ?Josef Moellers
| | `* why bash in $0 ?Janis Papanagnou
| |  +- why bash in $0 ?Josef_Möllers
| |  `* why bash in $0 ?Popping Mad
| |   +- why bash in $0 ?Josef_Möllers
| |   `- why bash in $0 ?Janis Papanagnou
| `* why bash in $0 ?Kaz Kylheku
|  +* why bash in $0 ?Felix Palmen
|  |`* why bash in $0 ?Popping Mad
|  | `* why bash in $0 ?Spiros Bousbouras
|  |  +* why bash in $0 ?Popping Mad
|  |  |`* why bash in $0 ?Felix Palmen
|  |  | `* why bash in $0 ?Popping Mad
|  |  |  +* why bash in $0 ?Felix Palmen
|  |  |  |`* why bash in $0 ?Helmut Waitzmann
|  |  |  | `* why bash in $0 ?Felix Palmen
|  |  |  |  `- why bash in $0 ?Helmut Waitzmann
|  |  |  +- why bash in $0 ?David W. Hodgins
|  |  |  `* why bash in $0 ?Keith Thompson
|  |  |   `- why bash in $0 ?Ruben Safir
|  |  `- dali_timer.sh (was: Re: why bash in $0 ?vallor
|  `* why bash in $0 ?Popping Mad
|   +* why bash in $0 ?Janis Papanagnou
|   |+- why bash in $0 ?Popping Mad
|   |`* why bash in $0 ?Popping Mad
|   | `- why bash in $0 ?Janis Papanagnou
|   `- why bash in $0 ?Kaz Kylheku
`* why bash in $0 ?Keith Thompson
 +* why bash in $0 ?Kenny McCormack
 |`- why bash in $0 ?Popping Mad
 +- why bash in $0 ?Popping Mad
 +- why bash in $0 ?Popping Mad
 `- why bash in $0 ?Popping Mad

Pages:12
Re: why bash in $0 ?

<u4tro5$pm1$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Sat, 27 May 2023 17:11:31 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u4tro5$pm1$1@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com> <u2cv2v$j78$1@reader2.panix.com>
<u2dj39$1sl7i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 27 May 2023 21:12:37 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="26305"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Content-Language: en-US
In-Reply-To: <u2dj39$1sl7i$1@dont-email.me>
 by: Popping Mad - Sat, 27 May 2023 21:11 UTC

On 4/27/23 06:34, Janis Papanagnou wrote:
> s sees what files the shell matched and provides an
> expanded matching files list (unless there's no match, in that case
> the literal 'x*' is passed).

flatbush:[ruben]:~$ cd ~/mnt/ ; ls *
AVF_INFO:
AVIN0001.BNP AVIN0001.INP AVIN0001.INT PRV00001.BIN

that lists the subdirectory

why bash in $0 ?

<u28b4u$6jn$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: why bash in $0 ?
Date: Tue, 25 Apr 2023 06:47:52 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u28b4u$6jn$1@reader2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 25 Apr 2023 10:47:58 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="6775"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
 by: Popping Mad - Tue, 25 Apr 2023 10:47 UTC

flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
root 339 2991 0 Apr09 tty3 00:00:00 -bash
ruben 1091 1090 0 Apr24 pts/5 00:00:00 -bash
ruben 7745 7743 0 Apr19 pts/8 00:00:00 bash
ruben 8999 8996 0 Apr17 pts/4 00:00:00 bash
ruben 9260 9258 0 Apr24 pts/1 00:00:00 bash
ruben 14427 14425 0 06:10 pts/6 00:00:00 bash
ruben 18922 14427 0 06:46 pts/6 00:00:00 grep --colour=auto bash
ruben 28570 28569 0 Apr24 pts/3 00:00:00 -bash
ruben 30315 30314 0 Apr24 pts/2 00:00:00 -bash
ruben 30844 30842 0 Apr23 pts/0 00:00:00 bash
ruben 31263 2986 0 Mar17 tty2 00:00:00 -bash

Re: why bash in $0 ?

<tnokhj-ep92.ln1@mail.home.palmen-it.de>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: felix@palmen-it.de (Felix Palmen)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Tue, 25 Apr 2023 13:05:01 +0200
Organization: palmen-it.de
Lines: 12
Message-ID: <tnokhj-ep92.ln1@mail.home.palmen-it.de>
References: <u28b4u$6jn$1@reader2.panix.com>
Injection-Date: Tue, 25 Apr 2023 13:05:01 +0200
Injection-Info: dont-email.me; posting-host="c0eda314cdc43c8c95b4d5ebab6b5116";
logging-data="902258"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zHSkz+Wi1pL5xkWsgPznD"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (FreeBSD/13.2-RELEASE (amd64)) tinews.pl/1.1.61
Cancel-Lock: sha256:oAxZHg1E+U/wLZViJu7AjAHyJHxRSiRVQYeoymhU1nc=
sha1:cx3aYyBBQBn/kuj0w+EdAIakabo=
X-PGP-Sig: GnuPG-v2 From,Newsgroups,Subject,Date,Injection-Date,Message-ID
iNUEARYIAH0WIQRpNhPVW79IN7ISOsxUreAGmHnyMQUCZEez3V8UgAAAAAAuAChp
c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0Njkz
NjEzRDU1QkJGNDgzN0IyMTIzQUNDNTRBREUwMDY5ODc5RjIzMQAKCRBUreAGmHny
MUsMAP9dyYs38I5ovz6jIUdbOIhltpDYcAdHZrZ5GFDbx6nk8wD9E32WC6n+lPuk
ViutaQ+EoAkqOHIcvVL0pyv97P5oTQQ=
=uBjg
X-PGP-Hash: SHA256
X-PGP-Key: 693613D55BBF4837B2123ACC54ADE0069879F231
 by: Felix Palmen - Tue, 25 Apr 2023 11:05 UTC

* Popping Mad <rainbow@colition.gov>:
> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"

Because you're obviously running that from bash?

I mean, what else would you expect there?

--
Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
{web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
{pgp public key} http://palmen-it.de/pub.txt // """""""""""
{pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

Re: why bash in $0 ?

<u29qed$5ud$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Tue, 25 Apr 2023 20:15:04 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u29qed$5ud$1@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Apr 2023 00:15:09 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="6093"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <tnokhj-ep92.ln1@mail.home.palmen-it.de>
 by: Popping Mad - Wed, 26 Apr 2023 00:15 UTC

On 4/25/23 07:05, Felix Palmen wrote:
> * Popping Mad <rainbow@colition.gov>:
>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>
> Because you're obviously running that from bash?
>
> I mean, what else would you expect there?
>

ps

Re: why bash in $0 ?

<87h6t3e814.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Tue, 25 Apr 2023 18:39:35 -0700
Organization: None to speak of
Lines: 19
Message-ID: <87h6t3e814.fsf@nosuchdomain.example.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de>
<u29qed$5ud$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="54381a60215576a88a03116a7e4d18f6";
logging-data="1160921"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CLSLyKQFNUPOniySAFWYM"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:qhU6QHAYeXsG76VgdmwazhT/Fvg=
sha1:ej5lQLbxykqR3CPkvP4JFVKdcYI=
 by: Keith Thompson - Wed, 26 Apr 2023 01:39 UTC

Popping Mad <rainbow@colition.gov> writes:
> On 4/25/23 07:05, Felix Palmen wrote:
>> * Popping Mad <rainbow@colition.gov>:
>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>
>> Because you're obviously running that from bash?
>>
>> I mean, what else would you expect there?
>>
>
>
> ps

"$0" is expanded by the bash process, not by the ps process.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */

Re: why bash in $0 ?

<kas6niF4o75U1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef.moellers@invalid.invalid (Josef Moellers)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 10:46:42 +0200
Lines: 22
Message-ID: <kas6niF4o75U1@mid.individual.net>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net g4gq+0RMVCi9jzzs4HVwSQwcgxj+YGRa7ri01JGYEkR7STtKIT
Cancel-Lock: sha1:eVopc0J+jjwrkj9dt1hn+sNQvEU=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <87h6t3e814.fsf@nosuchdomain.example.com>
 by: Josef Moellers - Wed, 26 Apr 2023 08:46 UTC

On 26.04.23 03:39, Keith Thompson wrote:
> Popping Mad <rainbow@colition.gov> writes:
>> On 4/25/23 07:05, Felix Palmen wrote:
>>> * Popping Mad <rainbow@colition.gov>:
>>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>>
>>> Because you're obviously running that from bash?
>>>
>>> I mean, what else would you expect there?
>>>
>>
>>
>> ps
>
> "$0" is expanded by the bash process, not by the ps process.
>
Hint: count the double quotes until you reach the $0, or better yet ...
toggle "inside"/"outside" each time you encounter one.
NB Not that the double quotes will prevent the $0 from bein expanded
when seen!

Josef

Re: why bash in $0 ?

<u2aq54$1art6$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!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: why bash in $0 ?
Date: Wed, 26 Apr 2023 11:16:20 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u2aq54$1art6$1@dont-email.me>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com> <kas6niF4o75U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Apr 2023 09:16:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="781df66d6d1de1dc1c3eb07b1f0705d0";
logging-data="1404838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rc517DRNIDTslO++3UoSG"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:IpIKApo5hlWcSEFTlfd5JpGEN4M=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <kas6niF4o75U1@mid.individual.net>
 by: Janis Papanagnou - Wed, 26 Apr 2023 09:16 UTC

On 26.04.2023 10:46, Josef Moellers wrote:
> On 26.04.23 03:39, Keith Thompson wrote:
>> Popping Mad <rainbow@colition.gov> writes:
>>> On 4/25/23 07:05, Felix Palmen wrote:
>>>> * Popping Mad <rainbow@colition.gov>:
>>>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>>>
>>>> Because you're obviously running that from bash?
>>>> I mean, what else would you expect there?
>>>
>>> ps
>>
>> "$0" is expanded by the bash process, not by the ps process.
>>
> Hint: count the double quotes until you reach the $0, or better yet ...
> toggle "inside"/"outside" each time you encounter one.

To "toggle" is a wrong advice _here_; for nested subshells,
like "$(basename "$0")" it is _counting_.

Janis

Re: why bash in $0 ?

<kas8h9F50e0U1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef@invalid.invalid (Josef Möllers)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 11:17:29 +0200
Lines: 25
Message-ID: <kas8h9F50e0U1@mid.individual.net>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com> <kas6niF4o75U1@mid.individual.net>
<u2aq54$1art6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net QiSaKyuRAs2uMZeNtriwzgVBp05W8CxrKHzOabiHa41irUys6Y
Cancel-Lock: sha1:JML369Fm9UIT+h1MhAqq+jcpcPM=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <u2aq54$1art6$1@dont-email.me>
 by: Josef Möllers - Wed, 26 Apr 2023 09:17 UTC

On 26.04.23 11:16, Janis Papanagnou wrote:
> On 26.04.2023 10:46, Josef Moellers wrote:
>> On 26.04.23 03:39, Keith Thompson wrote:
>>> Popping Mad <rainbow@colition.gov> writes:
>>>> On 4/25/23 07:05, Felix Palmen wrote:
>>>>> * Popping Mad <rainbow@colition.gov>:
>>>>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>>>>
>>>>> Because you're obviously running that from bash?
>>>>> I mean, what else would you expect there?
>>>>
>>>> ps
>>>
>>> "$0" is expanded by the bash process, not by the ps process.
>>>
>> Hint: count the double quotes until you reach the $0, or better yet ...
>> toggle "inside"/"outside" each time you encounter one.
>
> To "toggle" is a wrong advice _here_; for nested subshells,
> like "$(basename "$0")" it is _counting_.

I stand corrected!

Josef

Re: why bash in $0 ?

<u2b0e8$ef0$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 07:03:31 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2b0e8$ef0$1@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com> <kas6niF4o75U1@mid.individual.net>
<u2aq54$1art6$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Apr 2023 11:03:36 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="14816"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <u2aq54$1art6$1@dont-email.me>
 by: Popping Mad - Wed, 26 Apr 2023 11:03 UTC

On 4/26/23 05:16, Janis Papanagnou wrote:
> or nested subshells,
> like "$(basename "$0")" it is _counting_.

counting what?

Re: why bash in $0 ?

<kasichF6kvtU1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: josef@invalid.invalid (Josef Möllers)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 14:05:37 +0200
Lines: 11
Message-ID: <kasichF6kvtU1@mid.individual.net>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com> <kas6niF4o75U1@mid.individual.net>
<u2aq54$1art6$1@dont-email.me> <u2b0e8$ef0$1@reader2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net TB5v30g6H1LaxXAVVlto4QpkIkSvWExSQEEKdAKKiVP3PfwBN9
Cancel-Lock: sha1:VHflaqd00L5Qukg6xfdTnJfB9gs=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <u2b0e8$ef0$1@reader2.panix.com>
 by: Josef Möllers - Wed, 26 Apr 2023 12:05 UTC

On 26.04.23 13:03, Popping Mad wrote:
> On 4/26/23 05:16, Janis Papanagnou wrote:
>> or nested subshells,
>> like "$(basename "$0")" it is _counting_.
>
>
> counting what?

"count the double quotes"

Josef

Re: why bash in $0 ?

<u2b5i6$1cmki$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!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: why bash in $0 ?
Date: Wed, 26 Apr 2023 14:31:02 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <u2b5i6$1cmki$1@dont-email.me>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<87h6t3e814.fsf@nosuchdomain.example.com> <kas6niF4o75U1@mid.individual.net>
<u2aq54$1art6$1@dont-email.me> <u2b0e8$ef0$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Apr 2023 12:31:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="781df66d6d1de1dc1c3eb07b1f0705d0";
logging-data="1464978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lYRE3cfY7FUS6/IIQmoIs"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:C6FVgT3rpCvY9M/20HrQdduIqrI=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <u2b0e8$ef0$1@reader2.panix.com>
 by: Janis Papanagnou - Wed, 26 Apr 2023 12:31 UTC

On 26.04.2023 13:03, Popping Mad wrote:
> On 4/26/23 05:16, Janis Papanagnou wrote:
>> or nested subshells,
>> like "$(basename "$0")" it is _counting_.
>
>
> counting what?

Josef mentioned two cases; toggling and counting [of quotes].

Example for case 1, toggling: x="ab cd"*"de fg"
the first quote gets closed by the second one, unquoted *,
the third one gets closed by the fourth one.

Example for case 2, counting: echo "$(basename "$0")"
the $(...) subshell expansion opens its own new embedded
"quote space", so the first quote is closed by the fourth,
and the second one by the third.
"$(
"$0"
)"

Janis

Re: why bash in $0 ?

<87cz3qeib2.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 09:09:53 -0700
Organization: None to speak of
Lines: 23
Message-ID: <87cz3qeib2.fsf@nosuchdomain.example.com>
References: <u28b4u$6jn$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="54381a60215576a88a03116a7e4d18f6";
logging-data="1531787"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GsMXwK+p9PjJAVi7NEOa2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:uU0RR3stJFyJ+GVfUXxsF72KnWU=
sha1:e6njVw7Gr6TQeX4s+jddsLaIfmw=
 by: Keith Thompson - Wed, 26 Apr 2023 16:09 UTC

Popping Mad <rainbow@colition.gov> writes:
> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
> root 339 2991 0 Apr09 tty3 00:00:00 -bash
> ruben 1091 1090 0 Apr24 pts/5 00:00:00 -bash
> ruben 7745 7743 0 Apr19 pts/8 00:00:00 bash
> ruben 8999 8996 0 Apr17 pts/4 00:00:00 bash
> ruben 9260 9258 0 Apr24 pts/1 00:00:00 bash
> ruben 14427 14425 0 06:10 pts/6 00:00:00 bash
> ruben 18922 14427 0 06:46 pts/6 00:00:00 grep --colour=auto bash
> ruben 28570 28569 0 Apr24 pts/3 00:00:00 -bash
> ruben 30315 30314 0 Apr24 pts/2 00:00:00 -bash
> ruben 30844 30842 0 Apr23 pts/0 00:00:00 bash
> ruben 31263 2986 0 Mar17 tty2 00:00:00 -bash

I don't think you ever said what you're trying to accomplish. If your
question was based on idle curiousity, that's fine, but if you're trying
to do something specific (apparently filtering the output of `ps -ef`),
you need to tell us what your goal is.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */

Re: why bash in $0 ?

<u2bk2u$2susj$2@news.xmission.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 16:38:54 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <u2bk2u$2susj$2@news.xmission.com>
References: <u28b4u$6jn$1@reader2.panix.com> <87cz3qeib2.fsf@nosuchdomain.example.com>
Injection-Date: Wed, 26 Apr 2023 16:38:54 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3046291"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 26 Apr 2023 16:38 UTC

In article <87cz3qeib2.fsf@nosuchdomain.example.com>,
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>Popping Mad <rainbow@colition.gov> writes:
>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>> root 339 2991 0 Apr09 tty3 00:00:00 -bash
>> ruben 1091 1090 0 Apr24 pts/5 00:00:00 -bash
>> ruben 7745 7743 0 Apr19 pts/8 00:00:00 bash
>> ruben 8999 8996 0 Apr17 pts/4 00:00:00 bash
>> ruben 9260 9258 0 Apr24 pts/1 00:00:00 bash
>> ruben 14427 14425 0 06:10 pts/6 00:00:00 bash
>> ruben 18922 14427 0 06:46 pts/6 00:00:00 grep --colour=auto bash
>> ruben 28570 28569 0 Apr24 pts/3 00:00:00 -bash
>> ruben 30315 30314 0 Apr24 pts/2 00:00:00 -bash
>> ruben 30844 30842 0 Apr23 pts/0 00:00:00 bash
>> ruben 31263 2986 0 Mar17 tty2 00:00:00 -bash
>
>I don't think you ever said what you're trying to accomplish.

That is standard for these kinds of questions. To tell, would give the
game away.

>If your question was based on idle curiosity, that's fine, but if you're
>trying to do something specific (apparently filtering the output of `ps
>-ef`), you need to tell us what your goal is.

Again, the whole point of threads like this is for us to guess at what OP's
real problem is (if indeed, there is any and it is not just trolling). And
to fight amongst ourselves over whose interpretation is correct. As we are
now doing.

--
If you ask a Trumper who is to blame for the debacle of Jan 6, they will almost certainly say
something about Antifa/BLM/something/whatever. This shows just how screwed up they are; they can't
even get their narrative straight. What they *should* say is "Eugene Goodman". If not for him, the plot
would probably have succeeded, so he (Eugene) is clearly to blame for the failure.

Re: why bash in $0 ?

<20230426094148.257@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 16:44:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20230426094148.257@kylheku.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
Injection-Date: Wed, 26 Apr 2023 16:44:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="70c3e1c93b3018a94c4b9b7d9ef0314f";
logging-data="1543339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FiGqSKBvDqf/UtN8jkSMyK8S0ljusTXQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:kmVCdjVC4gLr/Yz32voUcf/4BHY=
 by: Kaz Kylheku - Wed, 26 Apr 2023 16:44 UTC

On 2023-04-26, Popping Mad <rainbow@colition.gov> wrote:
> On 4/25/23 07:05, Felix Palmen wrote:
>> * Popping Mad <rainbow@colition.gov>:
>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>
>> Because you're obviously running that from bash?
>>
>> I mean, what else would you expect there?
>>
>
>
> ps

Let's assume we have no idea that $0 is expanded by the shell before
it executes the command.

Why would we expect "ps", rather than "grep"?

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: why bash in $0 ?

<on2ohj-j0d1.ln1@mail.home.palmen-it.de>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: felix@palmen-it.de (Felix Palmen)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Wed, 26 Apr 2023 19:14:00 +0200
Organization: palmen-it.de
Lines: 30
Message-ID: <on2ohj-j0d1.ln1@mail.home.palmen-it.de>
References: <u28b4u$6jn$1@reader2.panix.com> <tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com> <20230426094148.257@kylheku.com>
Injection-Date: Wed, 26 Apr 2023 19:14:00 +0200
Injection-Info: dont-email.me; posting-host="a468f2ecbfe2036258b91ed34f862c43";
logging-data="1557330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CKNz0IATAPB56Wb4fwan1"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (FreeBSD/13.2-RELEASE (amd64)) tinews.pl/1.1.61
Cancel-Lock: sha256:dCVNqnxpcMVpGTY5IqnpSgHB2pfp9MMv4dyOWsElllw=
sha1:gamHzD1q6slrv9H/rkSjTzK2vAw=
X-PGP-Sig: GnuPG-v2 From,Newsgroups,Subject,Date,Injection-Date,Message-ID
iNUEARYIAH0WIQRpNhPVW79IN7ISOsxUreAGmHnyMQUCZElb2F8UgAAAAAAuAChp
c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0Njkz
NjEzRDU1QkJGNDgzN0IyMTIzQUNDNTRBREUwMDY5ODc5RjIzMQAKCRBUreAGmHny
MS8NAP9xDpogW9zL8xjrqrDkNWpM/iMAlXeyvcoo+d8Esn7eGgD9H5z3Y4ee1n04
Y6yWGqJbRvo797tdDquDe1uazDHckQk=
=84pY
X-PGP-Hash: SHA256
X-PGP-Key: 693613D55BBF4837B2123ACC54ADE0069879F231
 by: Felix Palmen - Wed, 26 Apr 2023 17:14 UTC

* Kaz Kylheku <864-117-4973@kylheku.com>:
> On 2023-04-26, Popping Mad <rainbow@colition.gov> wrote:
>> On 4/25/23 07:05, Felix Palmen wrote:
>>> * Popping Mad <rainbow@colition.gov>:
>>>> flatbush:[ruben]:~$ ps -ef | grep "$(basename "$0")"
>>>
>>> Because you're obviously running that from bash?
>>>
>>> I mean, what else would you expect there?
>>
>> ps

I see, this is an attempt to "reuse" a commandline, right? I mean,
"grep ps" would be horrible "hardcoding" ^^

> Let's assume we have no idea that $0 is expanded by the shell before
> it executes the command.
>
> Why would we expect "ps", rather than "grep"?

Then why "grep", rather than "basename"?

And then, we should finally see how $0 would be utterly pointless if
*not* expanded by the shell ;)

--
Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
{web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
{pgp public key} http://palmen-it.de/pub.txt // """""""""""
{pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

Re: why bash in $0 ?

<u2cv2v$j78$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 00:52:43 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cv2v$j78$1@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 04:52:47 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <20230426094148.257@kylheku.com>
 by: Popping Mad - Thu, 27 Apr 2023 04:52 UTC

On 4/26/23 12:44, Kaz Kylheku wrote:
> Why would we expect "ps", rather than "grep"?

actually, I would think it would be basename, not ps.

Re: why bash in $0 ?

<u2cv8u$j78$2@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 00:55:53 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cv8u$j78$2@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com> <on2ohj-j0d1.ln1@mail.home.palmen-it.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 04:55:58 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <on2ohj-j0d1.ln1@mail.home.palmen-it.de>
 by: Popping Mad - Thu, 27 Apr 2023 04:55 UTC

On 4/26/23 13:14, Felix Palmen wrote:
> And then, we should finally see how $0 would be utterly pointless if
> *not* expanded by the shell ;)

If it is always exanded by the shell prior to execution, it is then
always the name of the shell being invoked.. Does tht also not seem to
be pointless.

Re: why bash in $0 ?

<u2cvek$j78$3@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 00:58:55 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cvek$j78$3@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<87cz3qeib2.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 04:59:00 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <87cz3qeib2.fsf@nosuchdomain.example.com>
 by: Popping Mad - Thu, 27 Apr 2023 04:58 UTC

On 4/26/23 12:09, Keith Thompson wrote:
> I don't think you ever said what you're trying to accomplish. If your
> question was based on idle curiousity, that's fine, but if you're trying
> to do something specific (apparently filtering the output of `ps -ef`),
> you need to tell us what your goal is.
http://mywiki.wooledge.org/ProcessManagement#How_do_I_make_sure_only_one_copy_of_my_script_can_run_at_a_time.3F

Re: why bash in $0 ?

<u2cvk6$j78$4@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 01:01:53 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cvk6$j78$4@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<87cz3qeib2.fsf@nosuchdomain.example.com> <u2bk2u$2susj$2@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 05:01:58 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <u2bk2u$2susj$2@news.xmission.com>
 by: Popping Mad - Thu, 27 Apr 2023 05:01 UTC

On 4/26/23 12:38, Kenny McCormack wrote:
> Again, the whole point of threads like this is for us to guess at what OP's
> real problem is

No - but the cynicism is appreciated. It is ACTUALLY an attempt to
understand how it works with no specific task in mind.

Re: why bash in $0 ?

<u2cvrp$j78$5@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 01:05:56 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cvrp$j78$5@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<87cz3qeib2.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 05:06:01 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <87cz3qeib2.fsf@nosuchdomain.example.com>
 by: Popping Mad - Thu, 27 Apr 2023 05:05 UTC

On 4/26/23 12:09, Keith Thompson wrote:
> I don't think you ever said what you're trying to accomplish. If your
> question was based on idle curiousity, that's fine, but if you're trying
> to do something specific (apparently filtering the output of `ps -ef`),
> you need to tell us what your goal is.

It was an example I read somewhere that I tried to execute in order to
understand it...

Re: why bash in $0 ?

<u2cvsq$j78$6@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 01:06:29 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2cvsq$j78$6@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<87cz3qeib2.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 05:06:34 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="19688"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <87cz3qeib2.fsf@nosuchdomain.example.com>
 by: Popping Mad - Thu, 27 Apr 2023 05:06 UTC

On 4/26/23 12:09, Keith Thompson wrote:
> I don't think you ever said what you're trying to accomplish. If your
> question was based on idle curiousity, that's fine, but if you're trying
> to do something specific (apparently filtering the output of `ps -ef`),
> you need to tell us what your goal is.

It was an example I read somewhere that I tried to execute in order to
understand it...

Re: why bash in $0 ?

<csyCpiemCIwzXzKDM@bongo-ra.co>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 08:33:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <csyCpiemCIwzXzKDM@bongo-ra.co>
References: <u28b4u$6jn$1@reader2.panix.com> <tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com> <on2ohj-j0d1.ln1@mail.home.palmen-it.de> <u2cv8u$j78$2@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 27 Apr 2023 08:33:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0ea9675bfab26480d1c2cdb04c1e8e7e";
logging-data="1947948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gKqselfuj4ZM+5tbCgypX"
Cancel-Lock: sha1:SZGopZn6hb9Y3XrmLqshoeEJr6o=
X-Server-Commands: nowebcancel
In-Reply-To: <u2cv8u$j78$2@reader2.panix.com>
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Thu, 27 Apr 2023 08:33 UTC

On Thu, 27 Apr 2023 00:55:53 -0400
Popping Mad <rainbow@colition.gov> wrote:
> On 4/26/23 13:14, Felix Palmen wrote:
> > And then, we should finally see how $0 would be utterly pointless if
> > *not* expanded by the shell ;)
>
> If it is always exanded by the shell prior to execution, it is then
> always the name of the shell being invoked.. Does tht also not seem to
> be pointless.

It isn't always the name of the shell. Say I have a file named
my-beautiful-shell-script which contains only 1 line :
echo $0

..If I do bash my-beautiful-shell-script I see
my-beautiful-shell-script

If I make my-beautiful-shell-script have 2 lines :
#!/bin/bash
echo $0

and make it executable and execute it with ./my-beautiful-shell-script ,
I see
../my-beautiful-shell-script

Re: why bash in $0 ?

<u2dj39$1sl7i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!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: why bash in $0 ?
Date: Thu, 27 Apr 2023 12:34:16 +0200
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <u2dj39$1sl7i$1@dont-email.me>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com> <u2cv2v$j78$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 10:34:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ab1b4fe1a319646be3b495fc509942d7";
logging-data="1987826"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mto3mNZDwmKMH5PdqcrPG"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:KJjJ/g22sIv/4u0+uCLsCvyTVl8=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <u2cv2v$j78$1@reader2.panix.com>
 by: Janis Papanagnou - Thu, 27 Apr 2023 10:34 UTC

[ Post concerning expansion of basename "$0" ]

On 27.04.2023 06:52, Popping Mad wrote:
> On 4/26/23 12:44, Kaz Kylheku wrote:
>> Why would we expect "ps", rather than "grep"?
>
> actually, I would think it would be basename, not ps.

Ah, I see, thanks for clarifying. - This assumes that $0 is expanded
by the command using it as argument, i.e. the MD DOS approach; every
(raw!) text data passed with the call is expanded by the respective
command, so [in DOS] every command has to implement or call the same
argument parsing routines. - Unix shells are different; the shell is
doing expansions (typically expansions can be spotted by a '$', like
$var, ${var}, $(cmd), $((expr)), etc., or by the file globbing, *, ?,
[...], etc.) and the _expanded_ text is passed to the program. So in
basename "$0" ; ls x* ; # etc. (for example)
The command basename sees what is expanded by the shell (from where
you called it), ls sees what files the shell matched and provides an
expanded matching files list (unless there's no match, in that case
the literal 'x*' is passed). So an argument expansion with a $ will
not be seen literally by the program unless it is single quoted or
the $ escaped ('$0' or \$0). (The double quoting has also yet more
semantics (as opposed to no quoting), BTW; also important to know,
see "field-splitting" in the docs.)

This is how Unix shells work. It may make sense to take an hour or
two to read about "command processing" in shells; the command line
parsing process has a lot of steps that you shall be aware of if you
intend to program in shell.

Janis

Re: why bash in $0 ?

<u2e8o7$2m8$2@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.www.mrbrklyn.com!not-for-mail
From: rainbow@colition.gov (Popping Mad)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 12:43:46 -0400
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u2e8o7$2m8$2@reader2.panix.com>
References: <u28b4u$6jn$1@reader2.panix.com>
<tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com>
<20230426094148.257@kylheku.com> <on2ohj-j0d1.ln1@mail.home.palmen-it.de>
<u2cv8u$j78$2@reader2.panix.com> <csyCpiemCIwzXzKDM@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Apr 2023 16:43:51 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="www.mrbrklyn.com:96.57.23.83";
logging-data="2760"; mail-complaints-to="abuse@panix.com"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <csyCpiemCIwzXzKDM@bongo-ra.co>
 by: Popping Mad - Thu, 27 Apr 2023 16:43 UTC

On 4/27/23 04:33, Spiros Bousbouras wrote:
> If I make my-beautiful-shell-script have 2 lines :
> #!/bin/bash
> echo $0
>
> and make it executable and execute it with ./my-beautiful-shell-script ,
> I see
> ./my-beautiful-shell-script

Thank you.

But I fail to see the mechanism that would make that happen like that.
Why does it make a different from the command line than from a script?

Re: why bash in $0 ?

<hglqhj-hk9.ln1@mail.home.palmen-it.de>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: felix@palmen-it.de (Felix Palmen)
Newsgroups: comp.unix.shell
Subject: Re: why bash in $0 ?
Date: Thu, 27 Apr 2023 18:46:41 +0200
Organization: palmen-it.de
Lines: 15
Message-ID: <hglqhj-hk9.ln1@mail.home.palmen-it.de>
References: <u28b4u$6jn$1@reader2.panix.com> <tnokhj-ep92.ln1@mail.home.palmen-it.de> <u29qed$5ud$1@reader2.panix.com> <20230426094148.257@kylheku.com> <on2ohj-j0d1.ln1@mail.home.palmen-it.de> <u2cv8u$j78$2@reader2.panix.com> <csyCpiemCIwzXzKDM@bongo-ra.co> <u2e8o7$2m8$2@reader2.panix.com>
Injection-Date: Thu, 27 Apr 2023 18:46:41 +0200
Injection-Info: dont-email.me; posting-host="9184936e274c74784ffdfaf2200b145b";
logging-data="2115218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EYcL3+7kdCO2Ai4M1BhBx"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (FreeBSD/13.2-RELEASE (amd64)) tinews.pl/1.1.61
Cancel-Lock: sha256:gSFQ03kWk1uLHeiW5JeKElh080kCBEDA+0w1kcExvcU=
sha1:FBKEukYoYVYJNDe8laEfKlJA2Fg=
X-PGP-Sig: GnuPG-v2 From,Newsgroups,Subject,Date,Injection-Date,Message-ID
iNUEARYIAH0WIQRpNhPVW79IN7ISOsxUreAGmHnyMQUCZEqm8l8UgAAAAAAuAChp
c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0Njkz
NjEzRDU1QkJGNDgzN0IyMTIzQUNDNTRBREUwMDY5ODc5RjIzMQAKCRBUreAGmHny
MbKmAP46oOKQeru5KT8NXivfOuQv3gqoIK5+GxKp/PB1KF9I1wEA9pJZbytmhMjt
PH7Q37kPVkKA7tekklhFmui8NeLJ2Ag=
=Kf33
X-PGP-Hash: SHA256
X-PGP-Key: 693613D55BBF4837B2123ACC54ADE0069879F231
 by: Felix Palmen - Thu, 27 Apr 2023 16:46 UTC

* Popping Mad <rainbow@colition.gov>:
> But I fail to see the mechanism that would make that happen like that.
> Why does it make a different from the command line than from a script?

For a script, the script is (logically) the executable, the shell just
acts as an interpreter and will set $0 accordingly.

When you just type commands in an interactive shell, there's no
executable. Well, besides the shell itself of course.

--
Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
{web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
{pgp public key} http://palmen-it.de/pub.txt // """""""""""
{pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor