Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: /bin/sh $LINENO functions, and option names



I prefer local_lineno as it is less typing than lineno_fn_relative

Of course if you use -L then it doesn't matter, but...

On Thu, 8 Jun 2017, Robert Elz wrote:

Some of you might have noticed that I have committed the changes to
/bin/sh to enable the LINENO variable to work properly.

Part of that is an option to control whether LINENO counts from 1 in
every function (we we have historically - in all the 3 (closing on 4) years
since LINENO has worked at all...), and in the FreeBSD shell (from where
our previous implantation came), or continues counting lines from the
scriot in which the definition occurs (stdin counts as a "script" for
this purpose in our shell, but not in all) the way most other shells do.

The (very little) text in POSIX is not clear (to say the least) on this
issue.

So, we now have an option, which gets set (or unset) before a function is
defined, and controls which behaviour is adopted for that function.
(The function can also contain code to choose, and even switch, if it
desires, but that means adding non-portable code to it.)

When I first proposed this, I had invented some totally absurd gibberish
for the option name, and asked for suggestions for a better choice.

Exactly one suggestion was forthcoming, from <rudolf%eq.cz@localhost>, which was
lineno_fn_relative and so, given the lack of alternatives, that is what
I picked.

Now that the code has been committed, there as been (off-list) another
suggestion, "local[-]linenno" (which would be locallineno or local-lineno,
or I presume local_lineno would be OK as well.)

Since this is very new, and I doubt anyone has had time to embed the option
name in any scripts yet, we still have the opportunity to change it, if it
is done quickly...

So opinions, or more suggestions, welcome - but only in the next few days,
after that one will get picked, and presuming that the LINENO code has not
caused any more problems, I will request that it get pulled into netbsd-8
After that (after the request is made) there will be no more cosmetic
changes.

Note that the option also has a one char (flag) name, 'L', so "set -L"
is the same as "set -o lineno_fn_relative" (and of course, to disable,
with + instead of -).   The default for this option is "on" (set -L)
for compatibility with last week's NetBSD code.  That means if you want
to run a script that expects LINENO to behave like it does in other shells
(bash ksh93, etc) then "sh +L script" will do it.   Since 'L' for "LINENO"
is so obvious, I do not plan on changing that one...

kre


!DSPAM:5938b1bf282411904686409!



+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+


Home | Main Index | Thread Index | Old Index