summaryrefslogtreecommitdiffstats
path: root/Src/Modules
Commit message (Collapse)AuthorAgeFilesLines
* 54783: improve checkptycmdMikael Magnusson5 days1-0/+61
| | | | | | | | | | With the previous (and now fallback) version of checkptycmd(), doing this: zpty foo 'while read; do echo hi; done' zpty (or zpty -t foo) would hang forever, which seems counterintuitive to the purpose of listing processes (or testing if a process is running).
* 54767: zformat: replace -qn by spec quoting indicator syntaxdana2026-06-201-28/+30
|
* 54776: fix warnings from 54710Mikael Magnusson2026-06-162-7/+9
| | | | Some compilers warn if a label immediately precedes a variable declaration.
* 54753: zpty: register pty fd as FDT_MODULE so it isn't closed when forkingMikael Magnusson2026-06-141-2/+1
| | | | This lets us remove these mysterious braces too.
* 54721: illegal -> invalid, invalid option -> bad optionMikael Magnusson2026-06-142-2/+2
| | | | Combinations of options can remain invalid, though.
* 54714: add MB_NICECHAR and use itMikael Magnusson2026-06-141-6/+2
|
* 54713: fix multibyte error reporting in zparseoptsMikael Magnusson2026-06-141-3/+12
| | | | | | | | This one is complicated by the fact it's using fprintf. If the user passed a nonprintable char as an option, we shouldn't print that, which nicechar handles for us. Fixes 54077.
* 54710: handle multibyte arguments in error messagesMikael Magnusson2026-06-143-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | A lot of places check option strings char by char, then send that char to zwarn/zerr, instead of reading out the full multibyte character. Doing so is quite easy with unmeta_one in most cases, so just go ahead and do that. The print functions in fact expect a wchar_t for %c anyway. Also renames "unknown option" to "bad option" because that's what every other place calls it (also one place was missing the colon, added that). To reproduce the math errors, since it's slightly less obvious (you need a multibyte character that is also an invalid parameter name, otherwise it actually works fine) % zsh -c '(( ¯ ))' zsh:1: bad math expression: illegal character: ^ % zsh -c 'zmodload zsh/mathfunc; (( sin(1¯) ))' zsh:1: bad math expression: illegal character: ^ % zsh -c 'の=5; echo $(( の ))' # unchanged because it is working 5 Also adds some tests because B12 was looking very empty, not sure if this is the correct way to handle the intersection of possibly not compiled module with possibly not available UTF-8 locale, but X02 and some others do a similar thing with ZSH_TEST_LANG, though in those cases that's handled specially by comptest, not the test itself.
* 54731: Adapt gdbm code to named referencesPhilippe Altherr2026-06-091-23/+14
|
* 54705: ksh93: fix use after free of .sh.edcharMikael Magnusson2026-06-101-2/+1
| | | | | | | | | | | | | | | | | | % bindkey T foo % zle -N foo % foo() { emulate -L ksh; () { zle -M ${.sh.edchar} } } % zmodload zsh/ksh93 % [press T twice] \M-(\M-^Ak\M-<\M-G^? or alternatively, emulate ksh in the main shell and just define this, but then you have to make sure you're in a zsh -f shell so random things aren't entering functions in the background. % foo() { zle -M ${.sh.edchar} } the code tries to restore sh_edchar = sh_unsetval; in the else branch, but this doesn't ever run in the above scenario because we never enter or leave a function with ksh emulation enabled (or indeed at all).
* 54704 + 54728: remove obsolete workaround in ksh93 moduleMikael Magnusson2026-06-101-10/+0
| | | | | After 54475 changed deleteparamdef to use getnode2 instead, this workaround isn't needed anymore.
* 54475: Don't perform dereferencing when looking up certain special parametersPhilippe Altherr2026-06-082-4/+4
| | | | Tweaked to account for workers/54328
* unposted: fix NULL termination in ksh93Mikael Magnusson2026-06-081-0/+1
| | | | | | | | | | I'm not sure how I messed this up in 54558, but now it should be actually correct. I even tested it: % [[ foo = (#m)(#b)f(o)o ]] % zmodload -F zsh/ksh93 p:.sh.match % () { setopt localoptions ksharrays; typeset -p .sh.match } typeset -g -ar .sh.match=( foo o )
* 54669: add --disable-link-all-libs configure optionMikael Magnusson2026-06-075-22/+6
| | | | | | | | | | | | | | | | | | | | | | | When this is used, libraries only needed by specific modules will only be linked to those modules (currently libgdbm and libpcre2). When --enable-cap is used, the main shell also uses libcap functions so we want to link that either way. Speaking of the cap module, it did some weird thing where it always compiles but creates useless builtins that only error, which means you can't rely on zmodload to check if they'll work. I'm sure someone will complain about me changing this but I'm going to at least try it and see if someone has a good reason for it. The gdbm module also has a big ifdef for the whole module, but instead of dummy builtins it just does #error, so remove that. We won't try to compile it if the user didn't ask for it, and if the user asked for it and it wouldn't compile, configure won't create a Makefile. Using the ac_cv_ cache variables in db_gdbm.mdd also doesn't actually work properly, those will remain set and enable the module to be linked after you pass --disable-gdbm and you will get the aforementioned #error. Use the enable_gdbm variable instead, like pcre.mdd does (and also cap.mdd now that I evilly made it conditional on --enable-cap).
* 54617: fix lookup in $commands array when hashlistall is unsetMikael Magnusson2026-06-041-4/+14
| | | | | | | | | | | | | | | | While the documentation for the zsh/parameter module does state The zsh/parameter module gives access to some of the internal hash tables and commands This array gives access to the command hash table. , the latter entry does *also* say values are the pathnames of the files that would be executed when the command would be invoked. Change getpmcommand to always do a lookup via findcmd() if it the entry is not found in the hash and HASHLISTALL is unset. This will indirectly respect HASHCMDS and add the single entry if it is set, look it up in the hash if it was added and then HASHCMDS was unset, etc.
* 54625: remove .cvsignoredana2026-05-291-18/+0
|
* unposted: zformat: pass through %) with -qdana2026-05-271-7/+3
| | | | the behaviour in the original patch was not actually desirable
* 54602: zformat: add -qQ options to auto-escape %sdana2026-05-271-23/+99
| | | | + NEWS update
* 54589: remove dead code identified by scan-buildOliver Kiddle2026-05-263-8/+6
|
* 54591: fix new compiler warningsdana2026-05-232-6/+7
|
* unposted: fix missing return keyword in 54552Mikael Magnusson2026-05-221-1/+1
|
* 54580: zformat: better handle literal % in format stringdana2026-05-211-5/+10
|
* 54568: zformat: fix some misparse and overrun issuesMikael Magnusson2026-05-161-4/+8
| | | | | | | | | | | | Not closing a %( would simply read garbage memory % zformat -f result 'before%(a-after' 'a:hello' ; echo $result beforeaftera:hello % zformat -f result 'before%(a-after' 'a:hello' ; echo $result beforeafter# It was possible to overwrite the %% and %) sequences with arbitrary text, and %% was also undocumented. Hopefully nobody relied on this spacekey heater.
* 54567: zselect: don't pass fd>=FD_SETSIZE to FD_SETMikael Magnusson2026-05-161-0/+4
| | | | | | | | | | | | | | | | | | | zsh% zselect 2023 ==2815== Syscall param select(exceptfds) points to uninitialised byte(s) ==2815== at 0x4DDA2D6: select (in /lib64/libc-2.32.so) ==2815== by 0x4885937: bin_zselect (zselect.c:175) ==2815== by 0x410C5E: execbuiltin (builtin.c:506) ==2815== by 0x43A5FC: execcmd_exec (exec.c:4259) ==2815== by 0x433BE1: execpline2 (exec.c:2040) ==2815== by 0x432824: execpline (exec.c:1765) ==2815== by 0x431A7D: execlist (exec.c:1515) ==2815== by 0x4310E3: execode (exec.c:1296) ==2815== by 0x457D15: loop (init.c:223) ==2815== by 0x45C151: zsh_main (init.c:1933) ==2815== by 0x40FD61: main (main.c:93) ==2815== Address 0x1ffeffe5b0 is on thread 1's stack ==2815== in frame #1, created by bin_zselect (zselect.c:66) zselect: error on select: bad file descriptor
* 54566: zpty: fix some issuesMikael Magnusson2026-05-161-15/+31
| | | | | | | | | | | | | | | | | | | | | checkptycmd would sign extend a 0xff byte to -1, causing the byte to be dropped, read into an unsigned char instead the "last despairing effort" code read directly into the int, which would probably not work on big endian. read into a temporary unsigned char instead the FIONREAD path used a totally undeclared variable "val", declare it, and also initialize pollret to -1 for this path the USE_CYGWIN_FIX path error message would always report -1 as the fd it was unable to duplicate, report the original fd instead initial read before the main loop in ptyread forgot to metafy the byte avoid calling malloc with 0 length as this may be misinterpreted as oom don't try to open sfd if opening mfd failed
* 54565: watch: increase a quite tight bound on format lengthMikael Magnusson2026-05-161-3/+4
| | | | | And also make sure metafy won't write outside the buffer, it can in theory become twice as long, so use half the buffer size at most.
* 54564: termcap, terminfo: reset u, fix metafy confusionMikael Magnusson2026-05-162-23/+49
| | | | | | | | | | | | | | Ideally, these should just be unmetafy()d and passed to ncurses, but the reality is that ncurses will just segfault if we do that when the user passes a non-ascii value. % echo $terminfo[らしりれ] zsh: segmentation fault % echotc れりの zsh: segmentation fault The tparm values do seem to work fine with multibyte strings, so do unmetafy() for those.
* 54563: stat, system: minor fixesMikael Magnusson2026-05-162-4/+5
|
* 54562: random: Fix some bugs in the random moduleMikael Magnusson2026-05-162-21/+24
| | | | | | | | | | | | | | | | % echo $(( zrand_int(4294967295) )) zsh: Upper bound (4294967295) out of range: 0-4294967295 3910196459 read loop had incorrect condition as well as passing negative status codes on to the pointer arithmetic clz64 shifted by 1 bit instead of 2 remove incorrect comment (it applies to the case where max is 1, which is not very interesting) and some minor stuff
* 54561: regex: regfree on pattern where regcomp failed could be undefined ↵Mikael Magnusson2026-05-161-1/+1
| | | | behavior
* 54560: parameter: Fix some issues in the parameter moduleMikael Magnusson2026-05-161-17/+25
| | | | | | | | | | | | | | | use strtol, not strtod use WEXITSTATUS on returned status, though I'm not sure when this path can actually be taken? don't abort getting group names just because one name is missing storing ${(kv)parameters} in a copy and then reading that wouldn't say what type a nameref pointed to setting multiple options via options=( foo on ) didn't verify the option name before trying to set it, reporting it as a failure to set it instead
* 54559: nearcolor was missing the third grayscale entry in 88 color modeMikael Magnusson2026-05-161-6/+12
| | | | | | Adding a test for this is not trivial since tccolours is set directly from a termcap lookup, and is specifically documented in the code as "may not be set".
* 54558: ksh93: .sh.match handling with KSHARRAYS set was totally brokenMikael Magnusson2026-05-161-4/+6
| | | | | | | If (#m) was not active, the getsparam("MATCH") is always NULL, terminating the whole array. Copying zsh_match into *ap didn't advance the pointer, NULL terminating the pointer again. The array length was one short (MATCH in front and NULL terminator means it should be +2).
* 54557: langinfo: fix some metafy confusionMikael Magnusson2026-05-161-9/+4
| | | | | In practice, name is always ascii so this is all no-op anyway, but just in case someone models code on this, make it less likely to confuse them.
* 54556: langinfo.mdd check was always trueMikael Magnusson2026-05-161-1/+1
|
* 54555: fix in 52783 was incomplete, add same check in scangroup()Mikael Magnusson2026-05-161-0/+4
| | | | | | | | | | | % typeset -A .zle.hlgroups % zmodload -i zsh/hlgroup % : ${.zle.hlgroups[select]} % print ${(k).zle.esc} zsh: segmentation fault Also add check on !hlg too for paranoia, not sure if that can actually happen, but getgroup has the same check.
* 54554: curses: use setcchar in zccmd_bg if availableMikael Magnusson2026-05-161-2/+38
| | | | This allows using more than 256 color pairs.
* 54553: curses: free subwindows before parents or they don't get freed at allMikael Magnusson2026-05-161-10/+25
|
* 54552: curses: fix a few issuesMikael Magnusson2026-05-161-34/+30
| | | | | | | | | | | | | | | | | | | | | | | mouseinterval returns the old mouse interval, not a ok/err status. mousemask returns 0 on failure zccmd_bg called wattron/off directly for attributes, instead of storing them in the ch variable being passed to wbkgd so they weren't actually applied to the background. remove some extra 0 being passed to zwarnnam, and change one from zerrnam. fix a leak of w->children when deleting windows. check return value from mbrtowc and wctomb correctly. store attrs correctly in non-multibyte path. return error from zcurses position when given an invalid parameter name. if init_pair fails, retry with the same number next time.
* 54551: clone: minor style issueMikael Magnusson2026-05-161-3/+3
|
* 54550: cap: fix leaksMikael Magnusson2026-05-161-10/+16
|
* 54549: attr: various minor issuesMikael Magnusson2026-05-162-4/+6
| | | | | | | | | | | The flags parameter is always 0 so the precedence mistake doesn't actually matter. Attributes are quite unlikely to be over 2GB in length, but use the correct types. The module is load=no so the autofeatures isn't used, but be consistent and list all builtins in the mdd file.
* 54545: A few very minor things coverity complained aboutMikael Magnusson2026-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | Coverity CID 1692322 in Src/glob.c: i'm pretty sure this is a false positive so add a debug message just in case Coverity CID 1500752 in Src/Zle/compresult.c: remove unused assignment that also reads uninitialized pointer p And two that were just near other things it complained about Src/utils.c: Warn if maildir disappeared from under us Src/Modules/system.c: stray \n in zwarn message Src/subst.c: Use DIGBUFSIZE for buf holding digits This one would be a little hard to overflow in practice, you'd need a parameter at least 100000000000000 characters long, which is 100TB.
* 54544: Coverity CID 439086 fix potential leak of prog in ptyread()Mikael Magnusson2026-05-161-0/+2
| | | | | | | This was originally marked as a false positive because the allocation was done with PAT_STATIC; when that was later changed to PAT_ZDUP to avoid problems with signal handlers stomping on the memory, apparently this cleanup path was missed.
* 54542: Coverity CID 1692320 fix leak of match1Mikael Magnusson2026-05-161-1/+3
|
* 54548: zftp: fix some mistakesMikael Magnusson2026-05-161-11/+7
| | | | | | | | The freesession function randomly clearing the current session instead of the passed section is probably not great. The h_errno definition is repeated just above identically, which I would assume is a compile time error for anyone who has USE_LOCAL_H_ERRNO set.
* 54495: Add ztcp -s to shutdown a tcp fdMikael Magnusson2026-05-112-5/+48
| | | | | This lets you close tcp connections without losing data. Updating zshtcpsys is left as an exercise for someone else.
* 54494: Add zsocket -s to shutdown() a socket fdMikael Magnusson2026-05-111-1/+12
|
* 54493: socket: fix some issues with socket nameMikael Magnusson2026-05-111-1/+10
| | | | | | | | | | | | | | | | | | | | | If the passed name was too long, it was silently truncated. If it was exactly the max length, the string was not nul terminated. % zsocket -l aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==421== Syscall param socketcall.bind(my_addr.sun_path) points to uninitialised byte(s) ==421== at 0x4DD77D7: bind (in /lib64/libc-2.32.so) ==421== by 0x61FB31A: bin_zsocket (in /usr/local/lib64/zsh/5.9.0.3-test-mika/zsh/net/socket.so) ==421== by 0x4217BF: execbuiltin (in /usr/local/bin/zsh) ==421== by 0x433751: execcmd_exec (in /usr/local/bin/zsh) ==421== by 0x433D2B: execpline2 (in /usr/local/bin/zsh) ==421== by 0x434084: execpline (in /usr/local/bin/zsh) ==421== by 0x4359F8: execlist (in /usr/local/bin/zsh) ==421== by 0x4362A1: execode (in /usr/local/bin/zsh) ==421== by 0x44F7A1: loop (in /usr/local/bin/zsh) ==421== by 0x450AAD: zsh_main (in /usr/local/bin/zsh) ==421== by 0x4D01E69: (below main) (in /lib64/libc-2.32.so) ==421== Address 0x1ffeffd7ad is on thread 1's stack ==421== in frame #1, created by bin_zsocket (???:)
* 54383: Fix WATCH/watch tyingPhilippe Altherr2026-04-301-11/+4
|