1
0
Fork 0
mirror of https://github.com/MirBSD/mksh.git synced 2025-12-31 06:07:17 +00:00
No description
Find a file
tg 3f9f73eb52 add experimental(!) undocumented (for now) support for ksh-style
functions taking parameters; from a discussion with and for @navi@vlhl.dev
via https://social.vlhl.dev/objects/1bc8db98-19ea-4cec-ac2c-2ab3a22a1661

general idea is:

| function (a b=foo) name { … }

… is identical enough to…

| function name {
|	a=$1; shift
|	if (( $# )); then
|		b=$1; shift
|	else
|		b=foo
|	fi
|	…
| }

… and the following hold:

- the parenthesēs are needed; within, words are parsed, and whitespace
  (and even line continuations: function (⏎↹x⏎ ) name { … } is allowed)
- degrading to bash-style 'function () name () { … }' is not allowed
- this is only allowed for ksh-style functions, which, among other things,
  also do things like reset the shell flags on exit
- the words must begin with a variable name and an equals sign, unquoted,
  or be comprised solely of such variable name
  - arrays are NOT supported to avoid surprises: x[$(exploit; echo 0)]
  - these are checked at definition time
- words without equals sign are mandatory parameters
- words with equals sign are optional parameters
  - if the corresponding argument is missing, the RHS is substituted
  - which may be empty: function (x=) name
  - which is ONLY evaluated in that case and not if not used
- if you put mandatory parameters behind optional parameters, SOL
  - there is no nil value the user can use to get the default anyway
  - this considers variables as set and empty-or-not only, not unset
- errors (missing required argument) report for the lineno of the
  function invocation
- set -x output shows local=…;shift on the lineno of the definition
- restricted mode is honoured

this commit also reduces the amount of “volatile” in use, as a side bonus
2025-12-24 04:51:57 +00:00
Build.sh bit of configury/types fixes: 2025-12-23 19:26:17 +00:00
check.pl change (hopefully nōn-existing) ENV file name 2025-04-26 22:42:59 +00:00
check.t add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
dot.mkshrc refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
edit.c move the mark when inserting text 2025-12-23 21:49:52 +00:00
emacsfn.h refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
eval.c improve/fix rendering of I/O redirections in error outputs 2025-12-23 20:26:04 +00:00
exec.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
expr.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
exprtok.h refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
FAQ2HTML.sh refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
funcs.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
histrap.c major exec overhaul for latest POSIX idiocies, plus trap new POSIX feature -p 2025-05-22 17:07:51 +00:00
jehanne.c add patch for the Jehanne operating system, from Shamar on IRC 2017-12-22 16:30:00 +00:00
jobs.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
lalloc.c refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
lex.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
lksh.1 work around one groff version breaking when I work around sth. in the other 2025-06-20 17:32:06 +00:00
main.c bit of configury/types fixes: 2025-12-23 19:26:17 +00:00
Makefile bit of configury/types fixes: 2025-12-23 19:26:17 +00:00
mbsdcc.h - introduce mbito(x) and mbfto(x) to match mb{i,f}to{,l,ll}u(x) but 2025-12-08 01:25:11 +00:00
mbsdint.h - introduce mbito(x) and mbfto(x) to match mb{i,f}to{,l,ll}u(x) but 2025-12-08 01:25:11 +00:00
mirhash.h refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
misc.c refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
mksh.1 move the mark when inserting text 2025-12-23 21:49:52 +00:00
mksh.faq document the usage example for the previous commit, with working code 2025-12-23 22:06:36 +00:00
mksh.ico add the desktop shortcut / icon from mksh/Win32 so it may be used by everyone for mksh/Unix too 2013-07-25 16:18:25 +00:00
os2.c oops, this private function had a separate prototype; thanks @komh 2025-05-01 00:58:35 +00:00
rlimits.opt refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
sh.h add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
sh_flags.opt refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
shf.c major exec overhaul for latest POSIX idiocies, plus trap new POSIX feature -p 2025-05-22 17:07:51 +00:00
strlcpy.c refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
syn.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
tree.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
ulimit.c make read builtin check the variables it writes to are identifiers 2025-06-01 01:10:32 +00:00
ulimits.opt refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00
var.c add experimental(!) undocumented (for now) support for ksh-style 2025-12-24 04:51:57 +00:00
var_spec.h refresh accordingly; some UTF-8 → ASCII for portability 2025-04-25 23:15:02 +00:00