Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Reserve your abuse for your true friends. -- Larry Wall in <199712041852.KAA19364@wall.org>


devel / comp.unix.shell / Consequences of a hyphen as part of an identifier

SubjectAuthor
* Consequences of a hyphen as part of an identifierJanis Papanagnou
`* Re: Consequences of a hyphen as part of an identifierEd Morton
 +* Re: Consequences of a hyphen as part of an identifierEli the Bearded
 |`- Re: Consequences of a hyphen as part of an identifierJanis Papanagnou
 `- Re: Consequences of a hyphen as part of an identifierJanis Papanagnou

1
Consequences of a hyphen as part of an identifier

<t136h6$8et$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Consequences of a hyphen as part of an identifier
Date: Sat, 19 Mar 2022 01:01:42 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <t136h6$8et$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 00:01:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c1006e0bf8b5797bc1c73f5a3d9e9b39";
logging-data="8669"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18duvfKfAMsyGcHWLhA8qwr"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:8AglK6nojRWYOrXtkUZinOBJ1Iw=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 19 Mar 2022 00:01 UTC

From a post here I learned that bash (and zsh) allows a hyphen as
part of a function identifier.

Script:
f-g() { echo 2; return 2; }
f=7 g=3
echo $(( f-g ))
echo $( f-g )
c-d=9

Output:
4
2
...: c-d=9: command not found

Do you consider that a sensible extension?

Janis

Re: Consequences of a hyphen as part of an identifier

<t13ba6$68f$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Consequences of a hyphen as part of an identifier
Date: Fri, 18 Mar 2022 20:23:17 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <t13ba6$68f$1@dont-email.me>
References: <t136h6$8et$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 01:23:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b762af9e6173c984647f7b01c16e2f6a";
logging-data="6415"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tWgSDvNRQyhgpbtkocRTN"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:KQOthHnJaKb8psD0Cxkfj69HZ1I=
In-Reply-To: <t136h6$8et$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 220318-12, 3/18/2022), Outbound message
 by: Ed Morton - Sat, 19 Mar 2022 01:23 UTC

On 3/18/2022 7:01 PM, Janis Papanagnou wrote:
> From a post here I learned that bash (and zsh) allows a hyphen as
> part of a function identifier.
>
> Script:
> f-g() { echo 2; return 2; }
> f=7 g=3
> echo $(( f-g ))
> echo $( f-g )
> c-d=9
>
> Output:
> 4
> 2
> ...: c-d=9: command not found
>
>
> Do you consider that a sensible extension?

No, IMHO allowing more than C symbols (alphanumeric and underscore chars
starting with an alpha or underscore) for function and script names is
pointless, error-prone and annoying (trying to call foo_bar when the
script is named foo-bar or vice-versa). This appears to be a case of
"what can we do" over "what should we do".

Ed.

Re: Consequences of a hyphen as part of an identifier

<eli$2203182213@qaz.wtf>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: Consequences of a hyphen as part of an identifier
Date: Sat, 19 Mar 2022 02:35:13 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2203182213@qaz.wtf>
References: <t136h6$8et$1@dont-email.me> <t13ba6$68f$1@dont-email.me>
Injection-Date: Sat, 19 Mar 2022 02:35:13 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="13904"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Sat, 19 Mar 2022 02:35 UTC

In comp.unix.shell, Ed Morton <mortonspam@gmail.com> wrote:
> On 3/18/2022 7:01 PM, Janis Papanagnou wrote:
>> From a post here I learned that bash (and zsh) allows a hyphen as
>> part of a function identifier.

Aliases and functions seem to share nearly the same namespace that
filenames have. I use ^? and ^H as alias names to set the backspace
stty setting. The actual control characters, not the common display
form.

Ksh:

alias ="stty erase '^?'"
alias ="stty erase '^H'"

(In bash, I can set both aliases, but the ^? generates a "command not
found" error. ^H works. In ksh, both work.)

> > Script:
> > f-g() { echo 2; return 2; }
> > f=7 g=3
> > echo $(( f-g ))
> > echo $( f-g )
> > c-d=9
> >
> > Output:
> > 4
> > 2
> > ...: c-d=9: command not found

Variable names have a different set of rules, to be more "sensible".

> > Do you consider that a sensible extension?

Yes, since shell functions and aliases may be used to replace commands
on the path, they should have the same rules for the identifiers.

> No, IMHO allowing more than C symbols (alphanumeric and underscore chars
> starting with an alpha or underscore) for function and script names is
> pointless, error-prone and annoying (trying to call foo_bar when the
> script is named foo-bar or vice-versa). This appears to be a case of
> "what can we do" over "what should we do".

Or you haven't thought through the "replace a command on path" use.

Bash:
$ unalias [
$ [[ $HOME ]] && echo ja
ja
$ [ $HOME ] && echo ja
ja
$ alias [=[[
$ [ $HOME ] && echo ja
bash: conditional binary operator expected
bash: syntax error near `]'
$ [ $HOME ]] && echo ja
ja
$
Ksh gives me an error trying to use [ as an alias name. Bash lets me
define and use a function [, ksh tells me the name is invalid.

Bash:
$ unalias [
$ function [ { echo yo; }
$ [
yo
$

Elijah
------
is unlikely to use exotic alias or function names except for very niche tasks

Re: Consequences of a hyphen as part of an identifier

<t13i7h$8pv$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Consequences of a hyphen as part of an identifier
Date: Sat, 19 Mar 2022 04:21:21 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <t13i7h$8pv$1@dont-email.me>
References: <t136h6$8et$1@dont-email.me> <t13ba6$68f$1@dont-email.me>
<eli$2203182213@qaz.wtf>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 03:21:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c1006e0bf8b5797bc1c73f5a3d9e9b39";
logging-data="9023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/KHtCUmtINWx7g+UX2c8/"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:GxsJTn20s70pnN8bgOExTlkxl+E=
In-Reply-To: <eli$2203182213@qaz.wtf>
 by: Janis Papanagnou - Sat, 19 Mar 2022 03:21 UTC

On 19.03.2022 03:35, Eli the Bearded wrote:
> In comp.unix.shell, Ed Morton <mortonspam@gmail.com> wrote:
>> On 3/18/2022 7:01 PM, Janis Papanagnou wrote:
>>> Script:
>>> f-g() { echo 2; return 2; }
>>> f=7 g=3
>>> echo $(( f-g ))
>>> echo $( f-g )
>>> c-d=9
>>>
>>> Output:
>>> 4
>>> 2
>>> ...: c-d=9: command not found
>>> Do you consider that a sensible extension?
>
> Yes, since shell functions and aliases may be used to replace commands
> on the path, they should have the same rules for the identifiers.

Interesting thought.

But on the OS-level (defining commands) you can use almost every
existing character to specify names of commands.

Janis

Re: Consequences of a hyphen as part of an identifier

<t13kgc$peq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Consequences of a hyphen as part of an identifier
Date: Sat, 19 Mar 2022 05:00:12 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <t13kgc$peq$1@dont-email.me>
References: <t136h6$8et$1@dont-email.me> <t13ba6$68f$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Mar 2022 04:00:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c1006e0bf8b5797bc1c73f5a3d9e9b39";
logging-data="26074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Mtvm6jP/xrmim7ehYrYvl"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:HN09nfJ33x6DJAEToVUvTD01aFo=
In-Reply-To: <t13ba6$68f$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 19 Mar 2022 04:00 UTC

On 19.03.2022 02:23, Ed Morton wrote:
> On 3/18/2022 7:01 PM, Janis Papanagnou wrote:
>> From a post here I learned that bash (and zsh) allows a hyphen as
>> part of a function identifier.
>>
>> Script:
>> f-g() { echo 2; return 2; }
>> f=7 g=3
>> echo $(( f-g ))
>> echo $( f-g )
>> c-d=9
>>
>> Output:
>> 4
>> 2
>> ...: c-d=9: command not found
>>
>>
>> Do you consider that a sensible extension?
>
> No, IMHO allowing more than C symbols (alphanumeric and underscore chars
> starting with an alpha or underscore) for function and script names is
> pointless, error-prone and annoying (trying to call foo_bar when the
> script is named foo-bar or vice-versa). This appears to be a case of
> "what can we do" over "what should we do".

What I found disturbing with the above showed sample code is that the
lexical parsing isn't deterministic any more; in one context "f-g" is
tokenized as ID("f") OP("-") ID("g") and in the other context it's
ID("f-g"). Apart from the language parsing aspect it's also harder
for the coder (or code maintainer) to correctly interpret such code.

Janis

>
> Ed.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor