Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001050 [1003.1(2013)/Issue7+TC1] Base Definitions and Headers Editorial Enhancement Request 2016-04-30 14:43 2022-08-05 09:29
Reporter steffen View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Applied  
Name steffen
Organization
User Reference
Section 3. Definitions
Page Number 34, 70
Line Number 1168, 2015
Interp Status ---
Final Accepted Text Note: 0005903
Summary 0001050: Add support for the hyphen character in alias names and shell names
Description The use of hyphens in program names, e.g., for appareant clarification of
sub-definitions, e.g.,display-buttons, disable-paste, or sheer namespace
separation purposes, e.g., eu-ar, eu-ranlib etc., has over the past
almost two decades replaced the use of no separator or the underscore
character for the mentioned purposes. Compare, e.g., gpgparsemail,
gpgconf, unicode_start, unicode_stop.

The tested mksh, bash and yash support hyphens in alias and function
names in either position.
Desired Action Support the hyphen character in alias names and shell names.
Note the following doesn't talk about the possible necessity to use
a double-hyphen option parse terminator in order to support names which
start with a hyphen.

On page 34, lines 1168 ff., change

  3.10 Alias Name
  In the shell command language, a word consisting solely of underscores,
  digits, and alphabetics from the portable character set and any of the
  following characters: ’!’, ’%’, ’,’, ’@’.

to

  3.10 Alias Name
  In the shell command language, a word consisting solely of hyphens,
  underscores, digits, and alphabetics from the portable character set
  and any of the following characters: ’!’, ’%’, ’,’, ’@’.

On page 70, lines 2015 ff., change

  3.231 Name
  In the shell command language, a word consisting solely of
  underscores, digits, and alphabetics from the portable character set.
  The first character of a name is not a digit.

to

  3.231 Name
  In the shell command language, a word consisting solely of hyphens,
  underscores, digits, and alphabetics from the portable character set.
  The first character of a name is not a digit.
Tags issue8
Attached Files

- Relationships
related to 0001630Applied 1003.1(2016/18)/Issue7+TC2 Alias names 

-  Notes
(0003189)
shware_systems (reporter)
2016-04-30 14:55
edited on: 2016-04-30 15:17

3.10 Alias Name
  In the shell command language, a word consisting solely of underscores,
  digits, and alphabetics from the portable character set as a lead character
  and those plus any of the following characters:
     ’!’, ’%’, ’,’, ’@’ and '-' (hyphen)
  as trailing characters.

As hyphen is a single char, not char class, it goes with the other exceptions. Underscore is traditionally of class "identifier letter", not "punct", so can be a lead character. As a separator hyphen doesn't need to be first, nor are the others expected to be. '!' is problematic as the not operator, for one.

3.231 should not be changed, imo; hyphens apply to Command Names and Aliases as representative of those, not variables or other general Name usage.

(0003190)
kre (reporter)
2016-04-30 16:50
edited on: 2016-04-30 16:51

Re note 3189 ... underscore isn't a char class either, I see no problem
including hyphen with underscore, or moving both of them to the list of
characters that are supported.

I certainly agree that this should apply only to what are (effectively)
command names (whether then be actual file type commands, functions, or
aliases) and not shell var names, otherwise ${var-foo} would no longer
mean what it has meant forever (from even before the ':' form was added.)

But for command names, just adding hyphen is not really enough, the syntax
of all of those forms should be the same, anything that works as part of
a (simple) command name for a command found in /bin (or wherever - from
searching $PATH) should be acceptable in both alias and function names.

(0003191)
steffen (reporter)
2016-05-02 12:53

True.
I included 3.231 because of the wording in 2.9.5 Function Definition Command, page 2346, line 74657 and following:

  the application shall ensure that it is a name (see XBD Section 3.231)

So then there either needs to be a completely new entry in the Definitions to which this can refer, or it should be referred to Alias name instead, as .. suggested by you in @3189?
(0003192)
kre (reporter)
2016-05-02 14:58

Re:
   So then there either needs to be a completely new entry in the Definitions to
   which this can refer,

Why?

There is nothing similar for normal command names, they are just words, and
any shell word works. The same should be true of both alias names and
function names, or they are unable to serve as replacements for (all) commands.

For functions, there might want to be a note suggesting that '/' would be a
poor character to use in the name, as (because of the way functions are
detected) such a function can never be used (and allowing implementations to
reject function names containing '/') but there's no reason aliases should
not contain '/' (and the alias name definition allows it as an extension, along
with anything else) and no reason I can see for function names to be restricted
from including any other character (except probably \0).
(0003193)
dwheeler (reporter)
2016-05-02 18:59

Adding hyphens is fine, but *starting* with a hyphen should be forbidden or at least strongly discouraged. Since hyphens also lead options, having alias names that lead with options is extremely confusing.
(0003194)
kre (reporter)
2016-05-02 21:19

Re: but *starting* with a hyphen should be forbidden
    or at least strongly discouraged.

No, neither -- it isn't confusing at all. I have long (very long)
used just '-' as a command (it turns into the MH command "show prev",
I also have "+", which, unsurprisingly, is "show next")

Those work fine as scripts, and aren't confusing at all, options are
never first in a command (though they do mean extra care is needed with
eval, and exec gets tricky if it were ever useful) - they ought to
(and in most shells do) work fine as aliases, and similarly as
functions (where they do in only a few shells currently.)

If you wanted to ban something as confusing, it would be file names
that start with '-', but that's never going to happen, and is easy
to avoid problems with anyway.
(0003232)
ormaaj (reporter)
2016-05-26 13:52

I pretty much agree with kre. Aliases are actually more useful when their names are less restrictive. Any harm that comes from a bad alias name is self-inflicted. Their macro-like nature means the user of an alias must be aware of the currently defined aliases at all times and their potential interactions with other syntax regardless of what characters are allowed.

Bash for instance honors almost any alias name especially when it's assigned directly to BASH_ALIASES, except when it's impossible to do so like with metacharacters and characters that appear in tokens that would render a script unparsable.
(0003346)
Don Cragun (manager)
2016-08-11 23:10
edited on: 2016-08-11 23:11

Why would we want to add am ambiguity into the meaning of arithmetic expansions? If - is allowed in a variable name, what output should:
x=3
y=2
x-y=5
echo $((x-y))

print?

Furthermore, scripts using a shell conforming to the current standard expect the command (assuming the assignments in the above example are still in effect) expect the command:
echo $x-y

to print:
3-y

not:
5


(0003347)
kre (reporter)
2016-08-11 23:28

It is quite clear that shell variable names cannot be allowed to
contain '-' (and lots of other non-alphanumeric chars)- but there is no
reason at all that alias names, function names, etc need to use the same
syntax as variable names.

In fact, they should not - they should both use the same syntax as command
names, which in shell grammar, is "word".
(0003348)
philip-guenther (reporter)
2016-08-11 23:39

> Why would we want to add am ambiguity into the meaning of arithmetic expansions?
> If - is allowed in a variable name, <...>

Given the summary of this bug, that isn't what is wanted. To achieve what is wanted, the use of 'name' in section 2.5 "Parameters and Variables":
     A parameter can be denoted by a name, a number, or one of the special
     characters listed in Section 2.5.2. A variable is a parameter denoted
     by a name.

will need to be changed. I would suggest that a new definition be added "Variable Name", which matches the current "Name" definition, ala:
     In the shell command language, a word for designating a variable, consisting
     solely of underscores, digits, and alphabetics from the portable character
     set. The first character of a variable name is not a digit.

...and then 2.5 updated to reference that, ala:
     A parameter can be denoted by a variable name, a number, or one of the special
     characters listed in Section 2.5.2. A variable is a parameter denoted
     by a variable name.
(0003349)
Don Cragun (manager)
2016-08-12 01:05

In reference to Note: 0003347, Name as defined by XBD section 3.231 (Name) (which is what the Desired Action in this bug report wants to change to allow hyphens in a Name) is used in XCU section 2.6.2 (Parameter Expansion) specifying that the name of a variable following a "$" (when it is not surrounded by braces) is the longest string of characters as defined by the term Name; in XCU section 2.9.5 (Function Definition Command) to define the characters that can be used in the name of a function; XCU section 2.10.2 (Shell Grammar Rules) Rule 5 (NAME in for) to specify the name of the shell variable that is set by to the current iteration value in a for loop; and XCU section 2.10.2 (Shell Grammar Rules) Rule 7.b. (Assignment preceding command name) to specify whether a string containing an "=" will be treated as a WORD, a NAME, or an ASSIGNMENT_WORD (defining the name of the variable assigned to in an assignment) in the shell grammar.
(0003661)
steffen (reporter)
2017-04-06 12:46

How about

On page 34, lines 1168 ff., change

  3.10 Alias Name
  In the shell command language, a word consisting solely of underscores,
  digits, and alphabetics from the portable character set and any of the
  following characters: ’!’, ’%’, ’,’, ’@’.

to

  3.10 Alias Name
  In the shell command language, a word consisting solely of hyphen-minusses,
  underscores, digits, and alphabetics from the portable character set
  and any of the following characters: ’!’, ’%’, ’,’, ’@’.
  The first and last character may not be hyphen-minus.
(0005903)
geoffclare (manager)
2022-07-21 16:29

On page 34, lines 1168 ff., change
3.10 Alias Name
In the shell command language, a word consisting solely of underscores, digits, and alphabetics from the portable character set and any of the following characters: ’!’, ’%’, ’,’, ’@’.
to
3.10 Alias Name
In the shell command language, a word consisting solely of alphabetics and digits from the portable character set and any of the following characters: ’!’, ’%’, ’,’, '-', ’@’, '_'.

- Issue History
Date Modified Username Field Change
2016-04-30 14:43 steffen New Issue
2016-04-30 14:43 steffen Name => steffen
2016-04-30 14:43 steffen Section => 3. Definitions
2016-04-30 14:43 steffen Page Number => 34, 70
2016-04-30 14:43 steffen Line Number => 1168, 2015
2016-04-30 14:55 shware_systems Note Added: 0003189
2016-04-30 14:58 shware_systems Note Edited: 0003189
2016-04-30 15:17 shware_systems Note Edited: 0003189
2016-04-30 16:50 kre Note Added: 0003190
2016-04-30 16:51 kre Note Edited: 0003190
2016-05-02 12:53 steffen Note Added: 0003191
2016-05-02 14:58 kre Note Added: 0003192
2016-05-02 18:59 dwheeler Note Added: 0003193
2016-05-02 21:19 kre Note Added: 0003194
2016-05-26 13:52 ormaaj Note Added: 0003232
2016-08-11 23:10 Don Cragun Note Added: 0003346
2016-08-11 23:10 Don Cragun Note Edited: 0003346
2016-08-11 23:11 Don Cragun Note Edited: 0003346
2016-08-11 23:28 kre Note Added: 0003347
2016-08-11 23:39 philip-guenther Note Added: 0003348
2016-08-12 01:05 Don Cragun Note Added: 0003349
2017-04-06 12:46 steffen Note Added: 0003661
2022-07-21 16:29 geoffclare Note Added: 0005903
2022-07-21 16:29 geoffclare Interp Status => ---
2022-07-21 16:29 geoffclare Final Accepted Text => Note: 0005903
2022-07-21 16:29 geoffclare Status New => Resolved
2022-07-21 16:29 geoffclare Resolution Open => Accepted As Marked
2022-07-21 16:30 geoffclare Tag Attached: issue8
2022-08-05 09:29 geoffclare Status Resolved => Applied
2023-02-09 17:08 nick Relationship added related to 0001630


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker