1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-08-18 17:20:59 +02:00
Commit graph

426 commits

Author SHA1 Message Date
Peter Stephenson
47b7f2adef unposted: more care with shell function filename.
When updating shfunc structure to change filename we should be
careful to free whatever's there already, we may now be the
directory in which to find the function definition.  After loading
the field contains the full name of the file.
2017-01-11 12:11:22 +00:00
Peter Stephenson
f26d1ba6b0 Add features associated with autoloading a function using an absolute
path.

-d defaults to normal fpath

-r remembers the path without actually loading.  May be combined with -d.

-R does the same but it's an error if not found

-X can now take a directory path: this is used to output not yet loaded
functions that have an associated path.
2017-01-11 11:26:13 +00:00
Barton E. Schaefer
dc1f3aae60 40179: fix handling of "printf -" and "printf --"
unposted: regression test for 40179 / 37467
2016-12-14 11:01:09 -08:00
Barton E. Schaefer
efd3baf2a2 40134: silence spurious compiler warnings. 2016-12-10 19:13:53 -08:00
Daniel Shahaf
a81f280bfa 40010: builtins: Say 'bad option: +x', not 'bad option: -x', when +x was passed. 2016-11-28 07:16:38 +00:00
Oliver Kiddle
ee1222454e unposted: fix printf -v to an array without format string reuse 2016-11-23 11:52:12 +01:00
Peter Stephenson
a62e1640bc 39958: Add extra byte to PATH_MAX allocations.
This ensures we've got enough space for a null, although this
isn't always needed.
2016-11-17 19:49:17 +00:00
Peter Stephenson
a57977d01a 39870: ensure exit trap can always run 2016-11-08 13:02:57 +00:00
Barton E. Schaefer
d91ffb1db2 39838: another missing unqueue_signals() 2016-11-05 13:49:07 -07:00
Oliver Kiddle
5c28031ea6 39834: when print used with -v and -l, include a final newline
Also complete print -S option and make further use of the
new printf to an array feature in other completion functions.
2016-11-05 00:31:01 +01:00
Oliver Kiddle
4b41e33cbc 39389: when printf -v is used with an array use separate elements each time the format is reused 2016-11-05 00:27:47 +01:00
Barton E. Schaefer
ab81b98c49 39758: revise 39704 for array and hash parameters; more POSIXBUITINS tweaks for
export

39704 was commit 0f5e670, forgot to reference article number in that log.

"typeset -p" outputs "typeset" for array and hash parameters, even when
exported, because those types can be marked export but are never pushed
to the enviroment.

For POSIXBUILTINS, "export var" does not implicitly set $var, and its
export state is preserved when assigned (but not when explicitly unset).
2016-10-29 11:56:50 -07:00
Peter Stephenson
7e7e2d7e63 39678: metafication of printf %q argument and result 2016-10-19 10:39:58 +01:00
Peter Stephenson
276197d1d1 36108: command -[vV] assumed -p 2016-10-11 15:16:17 +01:00
Peter Stephenson
4ab3fcc90d 39545: Add some missing unqueue_signals().
All of these are added simply to fit existing logic in other branches.
2016-10-03 13:43:20 +01:00
Barton E. Schaefer
3608fa7961 39509: in the event the current directory has been removed, use chasedots semantics for "cd ..". 2016-09-30 15:52:08 -07:00
Peter Stephenson
07c8fbe596 34943: Fixes for "command" with multiple options.
These need to combine properly, and alos "command -p" with either
-v or -V needs to search for builtins and then using the default
system path.
2016-09-29 11:01:00 +01:00
Daniel Shahaf
f368720b8b 39252: internal: quotestring: Drop the 'e' parameter, which no caller uses. 2016-09-11 09:22:18 +00:00
Peter Stephenson
fe3a63fa6c 39181: Add PM_SINGLE and use for compstate.
This flags that compstate (or any other special) can only have
a single instance and an attempt to create a new one is an error.
Given the very fiddly semantics of compstate any other usage
seems pointless.

No investigation yet of other variables that could use this.

Note it's still possible to hide such variables; only instances
that keep the special nature are affected.
2016-09-06 09:42:33 +01:00
Jun-ichi Takimoto
acad0620ef 39087: fix 'conditionally uninitialized' variables 2016-08-23 18:18:50 +09:00
Daniel Shahaf
f9b1703511 38971: Start using the new arrlen_ge() / arrlen_le() helpers. 2016-08-01 08:01:29 +00:00
Oliver Kiddle
5ea32ce2fc 38752: add comments to explain use of stdout instead of stderr for the which builtin 2016-06-29 17:04:50 +02:00
Barton E. Schaefer
769bd4070a 38630: fix infinite loop of "hash =" 2016-06-07 10:08:02 -07:00
Barton E. Schaefer
9afb67eb65 unposted: silence spurious compiler warning 2016-04-29 13:15:33 -07:00
Barton E. Schaefer
e1c745a0dc 38306: in printf formats, treat a missing precision as zero rather than as unlimited 2016-04-22 10:12:17 -07:00
Barton E. Schaefer
95663e9365 37914: reparse associative array subscripts in "unset" so keys with "[" or "]" may be backslash-escaped
Also fix erroneous test case this revealed.
2016-02-08 20:52:11 -08:00
Peter Stephenson
7c59c953f2 37765: Use FS_FUNC on fucstack to find autoload -X target.
This is better than scriptname which can be updated due to e.g.
intervening "eval".
2016-01-25 16:23:16 +00:00
Peter Stephenson
1aec003155 37722: test builtin should return status 2 on syntax error 2016-01-21 16:30:21 +00:00
Peter Stephenson
0194b4ab1d 37646: Return non-zero status from typeset assigning readonly 2016-01-15 15:53:39 +00:00
Daniel Shahaf
5731581c4c 37551: Include the builtin's name in a "bad option" error message.
Example: «zsh -fc 'zle -z'» now prepends "zle:" to the error message.
2016-01-10 20:22:37 +00:00
Barton E. Schaefer
424b417063 unposted: Src/builtin.c: refine READ_MSTREAM to avoid unsequenced evaluation 2016-01-08 20:36:50 -08:00
Barton E. Schaefer
fac7466d11 37513: fix typos; improve error cleanup and correct for signed/unsigned compiler warning 2016-01-06 14:05:02 -08:00
Barton E. Schaefer
a940d25b18 37504: refactor code using/simulating memstream to capture output for "print -v" 2016-01-05 12:50:12 -08:00
Barton E. Schaefer
bc703e4ad1 37503: detect incompatible "print" options, fix metafication and possible memory leak, miscellaneous cosmetics 2016-01-04 22:50:48 -08:00
Jun T
ead199291f 37501 (+ revise test): correct byte counts when simulating memstream via temp file 2016-01-04 22:29:37 -08:00
Barton E. Schaefer
63c6d1746c 37497: handle NUL bytes in "printf -v". 2016-01-02 13:57:35 -08:00
Barton E. Schaefer
03adf52414 37493: readonly + POSIX_BUILTINS == typeset -gr 2016-01-02 12:40:31 -08:00
Barton E. Schaefer
6e10224f1e unposted: enable WARN_CREATE_GLOBAL for print -v 2015-12-31 12:44:25 -08:00
Barton E. Schaefer
15b73ea99b 37467: add "print -v var" / "printf -v var" 2015-12-31 12:38:10 -08:00
Peter Stephenson
67877f6055 37364: "test" and "[" handling of parentheses.
If three arguments, need to prefer binary operators if possible.

Need to look for full string for parentheses.
2015-12-09 16:40:08 +00:00
Peter Stephenson
b0323cab3b 37187: infinite loop in "hash -m" 2015-11-22 16:25:06 +00:00
Peter Stephenson
72a67716ac 20974: Bug with scalar assignment to special array in typeset 2015-11-20 11:18:16 +00:00
Barton E. Schaefer
30b90f166e 37080: use paramtab abstraction more consistently, add explanatory comments 2015-11-08 12:44:31 -08:00
Peter Stephenson
ba36967b57 37038: add -l option to emulate to list options in emulations 2015-11-01 18:12:40 +00:00
Peter Stephenson
0628802baf 37014: Improved internal parameter setting.
Enhance WARNCREATEGLOBAL to work in many more cases.

Don't create REPLY as an integer if it didn't previously exist
as one, even if the value to be set is integral, as this is likely to
mess up later uses of REPLY.
2015-10-29 15:01:07 +00:00
Barton E. Schaefer
8abe1496fb 36256: local options should remain in effect for "emulate -L" even if additional option settings are applied 2015-08-21 13:38:19 -07:00
Peter Stephenson
61afb8dc8d 36262: Replace fix for missing unmeta in chdir().
It was needed in the argument to one of a pair of lchdir()s rather
than within zchdir().

Add tests for the case of a character with 0x83 within it.
2015-08-21 10:04:13 +01:00
Peter Stephenson
f8164fb647 36227: attempt to fix metafication problem with ztrftime.
fmt is treated as metafied on entry; use returned length to ensure
we metafy or output the correct length if there are embedded nulls.
2015-08-18 16:20:48 +01:00
Peter Stephenson
6fa8708bfc 36083: set array value when consistently retying scalar and array 2015-08-10 20:30:09 +01:00
Peter Stephenson
17d52d69ec Fix retying variables in opposite order.
Now gives an error.
Add test.
2015-08-09 19:10:01 +01:00
Daniel Shahaf
1122d83a6e 36008: trap: Fix listing of traps created under non-alias non-canonical signal spelling 2015-08-08 21:43:49 +00:00
Daniel Shahaf
32669e77f4 unposted: Typo fix. 2015-08-04 10:41:25 +00:00
Peter Stephenson
eb08892dcf 35635: a bit more consistency about making elements local 2015-06-27 21:19:26 +01:00
Peter Stephenson
420bfcfc66 35623: All is_array assignments should be treated as having a value. 2015-06-27 17:46:03 +01:00
Peter Stephenson
42b9037ae5 35613: Handle array slices in typeset 2015-06-26 14:55:35 +01:00
Peter Stephenson
9265e49ccb typeset silent on repeated typeset x=() 2015-06-25 17:45:15 +01:00
Peter Stephenson
39b28980f3 various posts: Implement assignment parsing for typeset.
Typeset assignments now work like raw assignments except
for no "+=" and no GLOB_ASSIGN.

Documented in typeset builtin doc and mentioned in release notes.

Tests to ensure basic sanity.

Enabled by default, can be turned off by "disable -r" with typeset
family of commands.
2015-06-24 10:21:12 +01:00
Peter Stephenson
f1923bdfa6 Add non-metafied character length handling.
Use this in regex module and add test using $'\ua0'.

Rename mb_metacharinit() to mb_charinit() as it does not involve
metafied characters.
2015-06-12 09:30:39 +01:00
Oliver Kiddle
ac26fafa03 35412: fix for - flag when formating strings with printf 2015-06-07 23:07:26 +02:00
Barton E. Schaefer
229bc3cc74 35350: extend "fc -I" to cover listing of "internal" history events only 2015-06-06 12:31:47 -07:00
Peter Stephenson
2abba7243a 35386: expand tabs where useful in builtins outputing function.
Also add to zed -f.

Option is -x <numm>.
2015-06-05 11:21:22 +01:00
Peter Stephenson
93e72ed1e9 35353: print -x and print -X expand tabs 2015-06-02 09:17:04 +01:00
Barton E. Schaefer
911edc5ea4 users/20238: add "fc -L" to operate only on the local shell history
Also avoid invoking the editor on empty results.
2015-05-30 15:22:09 -07:00
Peter Stephenson
2b08d0ed67 35318: POSIX_BUILTINS behaviour for getopts.
It needs to keep OPTIND, as well as the index within the
string pointed to by OPTIND, global in this case.
2015-05-28 18:32:39 +01:00
Peter Stephenson
ff19094669 35193: Add "unalias -a". 2015-05-18 16:57:08 +01:00
Oliver Kiddle
63ffbab84d Øystein Walle: 34841 (tweaked): allow grouping of thousands in printf format string 2015-05-14 22:56:24 +02:00
Peter Stephenson
85a4cf9b36 35110: don't implicitly initialize restricted integers to zero 2015-05-14 09:28:57 +01:00
Peter Stephenson
ec57c91b58 users/20203: nested functions in always blocks when exit pending 2015-05-13 16:17:04 +01:00
Mikael Magnusson
1e6fb1a4f0 Fix two bugs in typeset_setbase 2015-05-04 04:26:11 +02:00
Peter Stephenson
bf258a1c07 34992: POSIX fix for readonly variables.
With POSIXBUILTINS, variables can be marked readonly if unset.
Also, variables can't have the readonly flag removed.
2015-04-29 15:54:49 +01:00
Barton E. Schaefer
d4f50f2d18 34851: fix thinko from 34093 that short-circuited some "whence -m" searches 2015-04-06 10:26:57 -07:00
Barton E. Schaefer
2335d62548 34551: Avoid adding an extra "/" to the target path in cd_try_chdir() when the current directory is "/" 2015-02-15 20:20:03 -08:00
Mikael Magnusson
0209635832 34490: Fix leak on print -zf/-sf error 2015-02-10 13:03:51 +01:00
Mikael Magnusson
2dbbc88d0b 34488: Fix use-after-free for print -zf and print -sf 2015-02-10 13:03:49 +01:00
Peter Stephenson
12b813b589 34331: better handling of NULL in cd.
Problem was return from symbolic link expander in weird cases
where there file system isn't behaving itself properly.
2015-01-22 20:20:15 +00:00
Peter Stephenson
0e3548994e 34329: add -S option to which and where 2015-01-20 17:31:28 +00:00
Barton E. Schaefer
3495dc5c27 34213: in previous patch, do not change usepm if it is already set 2015-01-10 10:32:31 -08:00
Barton E. Schaefer
daa788d88b 34212: do not change unset-ness of special parameters when exporting them 2015-01-10 10:32:31 -08:00
Peter Stephenson
cfd91eac07 Rearrange context saving.
Variables are now associated with the module that declares them, being
initialised and saved/restored there.  However, as many variables are
used for communication between modules, many of them are set in multiple
places, so the assignment is ambiguous.
2015-01-09 21:33:39 +00:00
Mikael Magnusson
bc55ddf364 Fix a typo in bin_print error message 2015-01-09 12:37:25 +01:00
Barton E. Schaefer
93846edb0d 34154/34155: reorder bin_print() to avoid leaking the output descriptor when incorrect/incompatible options were passed 2015-01-07 22:45:46 -08:00
Mikael Magnusson
1507719d0a 34112: typeset: fix leak of oldval
Found by Coverity (Issue 1255803).
2015-01-06 23:47:30 +01:00
Mikael Magnusson
5a9be69185 34113: whence: use dupstring to not leak memory
All other assignments to buf use the heap, and it's never freed. Found
by Coverity (Issue 1255786).
2015-01-06 23:47:12 +01:00
Mikael Magnusson
a150563fb0 34114: emulate: Handle aborting from mixed -L/-c correctly
Somehow Coverity found this (Issue 1255797, Failure to restore non-local value).
2015-01-06 23:45:09 +01:00
Barton E. Schaefer
f9cc5a6e56 34093: "whence" should always return nonzero when it finds that nothing matches its arguments 2015-01-06 09:33:44 -08:00
Peter Stephenson
454bb777cf users/19671: remove confusion with whence -a.
If the argument is a full path don't try to search the path for it.
2015-01-02 22:25:24 +00:00
Peter Stephenson
33d1439fdb users/19667: whence -S shows intermediate steps in symlink expansion 2015-01-02 21:32:51 +00:00
Jun Kuriyama
e12b515082 33984: bin_dirs() should use zputs() to print metafied directory names 2014-12-16 23:40:32 -08:00
Peter Stephenson
d067ebcacd 33876: etc.: Separate errors and keyboards interrupts
Combination of 12 commits from interrupt_abort branch.

Basic strategy is to introduce bits to errflag and to set and
reset them separately.

Remove interrupt status on return to main keymap.

Turn off ERRFLAG_INT for always block.

Restore bit thereafter: we probably need a new variable in order
to allow user interrupts to be reset in the always block.

Add TRY_BLOCK_INTERRUPT

This works the same as TRY_BLOCK_ERROR, but for a SIGINT, too.

Ensure propagation of SIGINT from exited job.

If received by foreground job, shell uses ERRFLAG_INT, not
ERRFLAG_ERROR, to set the new state.

Reset errflag before precmd()

Add always block in _main_completion to fix ZLS_COLORS

Ensures we get the right state of $ZLS_COLORS at the end of _main_complete
even if there's an interrupt.  However, the "right state" is a bit messy
as it depends on styles.
2014-12-11 09:41:17 +00:00
Barton E. Schaefer
53344183e1 33656: different algorithm for "whence -am" to produce results more consistent with "whence -m"
This uses the scanmatchtable routine to collect the names that match the
input pattern, then uses the original -a path search loop to generate
the output, to avoid duplicating test conditions and output formats.
2014-11-13 09:20:46 -08:00
Peter Stephenson
0ccbc3873f Handle -a option to whence in combination with -m. 2014-11-08 20:49:07 +00:00
Barton E. Schaefer
605a73e415 33429: disallow non-integer values for HISTSIZE and SAVEHIST of "fc -p", and fix crash on zero values for same 2014-10-10 23:12:57 -07:00
Oliver Kiddle
00a654af5c 33323: fix bug in removing math functions and complete -M option to functions 2014-10-02 19:29:32 +02:00
Peter Stephenson
d3d0910293 32918: add %. to ztrftime for use in prompts 2014-07-30 12:10:15 +01:00
Barton E. Schaefer
77119afe19 unposted (see 32892): 'fc -I' is an error 2014-07-24 08:33:13 -07:00
Peter Stephenson
880020ca2e 32624: use correct scaling factor (clock ticks) for times 2014-05-29 21:40:33 +01:00
Peter Stephenson
a06cd1766a 32479: POSIXTRAPS and implicit return values.
With POSIXTRAPS never propagate implicit return value.
In any case if not forcing a return value don't use lastval
from within the trap, use the one from the surrounding code.
2014-03-14 12:52:41 +00:00
Peter Stephenson
ed44ddad22 32246: option "shift -p" pops arguments from end of array 2014-01-11 19:31:29 +00:00
Peter Stephenson
c866657a3c 31706: standardize handling of "test ! <x> <y> <z>" 2013-09-06 20:37:40 +01:00
Barton E. Schaefer
935758ab7f 31637: be more selective about retry of lchdir() in cd_do_chdir()
Change of directory should not be retried relative to the current directory
when it has already failed along some path that does not refer to the
current directory.
2013-08-18 20:24:45 -07:00