1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-12-28 16:15:02 +01:00
Commit graph

11519 commits

Author SHA1 Message Date
Bart Schaefer
f85cb45045 Merge branch 'typesettounset' into declarednull
Adds 'setopt typeset_to_unset', documentation, failure tests for POSIX incompatibilies, etc.
2021-04-13 21:30:06 -07:00
Bart Schaefer
0793ce4e61 unposted (cf. 48469): document oddness of ${emptystr[(i)]}. 2021-04-13 21:18:35 -07:00
Bart Schaefer
fbc1125316 Change DECLAREDNULL to DEFAULTED 2021-04-13 21:18:35 -07:00
Bart Schaefer
f621fb7ab8 Fix ${(t)var} output, add comparative test cases 2021-04-13 21:18:35 -07:00
Bart Schaefer
dcd4439a9f Missed files from POSXIBUILTINS commit 2021-04-13 21:18:35 -07:00
Bart Schaefer
3099e79d25 Make DECLAREDNULL require POSIXBUILTINS and introduce a new test file.
V10private has been made agnostic to POSIXBUILTINS.
2021-04-13 21:18:35 -07:00
Bart Schaefer
69bd4a197c Final repairs for declared state of tied arrays
Fixups still required in bin_typeset, but assignments to scalar work.
2021-04-13 21:18:35 -07:00
Bart Schaefer
733c166115 Additional tied-array cleanup when tied scalar had a previous value 2021-04-13 21:18:35 -07:00
Bart Schaefer
ec4093659b Unset of a tied local scalar previously left it using tiedarr_gsu 2021-04-13 21:18:35 -07:00
Bart Schaefer
709af2bf3c Partial fix for handling of tied arrays.
As of this commit when a tied array is declared but neither the scalar
nor the array has an initializer, the array is initialized to empty.

The scalar struct param of a tied pair stores a direct pointer to the
internal array value of the array struct param, and upon assignment
modifies it without referring to the containing struct.  This means
that there's no opportunity to clear the PM_DECLAREDNULL bits on both
structs when the scalar is assigned.  Conversely, assigning to the
array does use the struct for the scalar.
2021-04-13 21:18:35 -07:00
Bart Schaefer
d0a25afe32 Choose a better bit-value for PM_DECLARED 2021-04-13 21:18:34 -07:00
Bart Schaefer
dddae7f055 Add PM_DECLARED and PM_DECLAREDNULL parameter flags.
This addresses the issue that "typeset foo" creates $foo set to an
empty string, which differs from typeset handling in bash and ksh.
It does this by concealing the internal value rather than alter
the way internal values are defaulted.

This imposes the following changes:

A typeset variable with no assignment triggers NO_UNSET warnings
when the name is used in parameter expansion or math.

The typeset -AEFHLRTZailux options are applied upon the first
assignment to the variable.  Explicit unset before the first
assignment discards all of those properties.  If any option is
applied to an existing name, historic behavior is unchanged.

Consequent to the foregoing, the (t) parameter expansion flag
prints nothing until after the first assignment, and the (i)
and (I) subscript flags also print nothing.

The bash behavior of "unset foo; typeset -p foo" is NOT used.
This is called out as an emulation distinction, not a change.

The test cases have not been updated, so several now fail.
The test harness has been updated to declare default values.
2021-04-13 21:18:34 -07:00
Daniel Shahaf
9dc195120c 48522: README: Clarify _alternative change 2021-04-13 16:54:03 -05:00
Bart Schaefer
fefd3854b4 48487 (amended): Failure test for math evaluation oddity
This was inadvertently included with TYPESET_TO_UNSET, so only the amendment is included here.
2021-04-13 14:22:11 -07:00
Tim Lee
3b631babec 48525: vcs_info git docs: ahead/behind commits: Run fewer external programs 2021-04-13 13:55:48 +00:00
Bart Schaefer
6c9a1f5e80 Update descriptive test for POSIX $((inf)) failure 2021-04-12 15:43:23 -07:00
Bart Schaefer
3811abe01c Completion system assumes typeset does initialize declared variables. 2021-04-12 14:45:48 -07:00
Bart Schaefer
b3613e4895 Change TYPESET_DOES_NOT_SET to TYPESET_TO_UNSET to avoid double-negative 2021-04-12 13:59:06 -07:00
Jun-ichi Takimoto
a90d5ab901 48439: remove macros that became unnecessary by df48cc8 2021-04-12 14:42:29 +09:00
Oliver Kiddle
704d10989e 48504: use SEEK_ macros in fseek() calls 2021-04-11 22:26:36 +02:00
Michael Stapelberg
6388156233 45396: readhistfile: avoid thousands of lseek(2) syscalls via ftell() 2021-04-11 21:38:27 +02:00
Marc Chantreux
82ba2261ab 48466: correct indentation and remove tabs and trailing spaces 2021-04-11 21:32:18 +02:00
Marc Chantreux
80d5210195 48445: pluralize tags in _surfraw 2021-04-11 21:05:39 +02:00
Marc Chantreux
90352a8278 users/26645: update options in gv completion 2021-04-11 20:49:30 +02:00
brian m. carlson
f7a417388c 47794: exec: run final pipeline command in a subshell in sh mode
zsh typically runs the final command in a pipeline in the main shell
instead of a subshell.  However, POSIX specifies that all commands in a
pipeline run in a subshell, but permits zsh's behavior as an extension.
The default /bin/sh implementations on various Linux distros and the
BSDs always use a subshell for all components of a pipeline.

Since zsh may be used as /bin/sh in some cases (such as macOS Catalina),
it makes sense to have the common sh behavior when emulating sh, so do
that by checking for being the final item of a multi-item pipeline and
creating a subshell in that case.

From the comment above execpline(), we know the following:

 last1 is a flag that this command is the last command in a shell that
 is about to exit, so we can exec instead of forking.  It gets passed
 all the way down to execcmd() which actually makes the decision.  A 0
 is always passed if the command is not the last in the pipeline. […]
 If last1 is zero but the command is at the end of a pipeline, we pass
 2 down to execcmd().

So there are three cases to consider in this code:

• last1 is 0, which means we are not at the end of a pipeline, in which
 case we should not change behavior.
• last1 is 1, which means we are effectively running in a subshell,
 because nothing that happens due to the exec is going to affect the
 actual shell, since it will have been replaced.  So there is nothing
 to do here.
• last1 is 2, which means our command is at the end of the pipeline, so
 in sh mode we should create a subshell by forking.

input is nonzero if the input to this process is a pipe that we've
opened.  At the end of a multi-stage pipeline, it will necessarily be
nonzero.

Note that several of the tests may appear bizarre, since most developers
do not place useless variable assignments directly at the end of a
pipeline.  However, as the function tests demonstrate, there are cases
where assignments may occur when a shell function is used at the end of
a command.  The remaining assignment tests simply test additional cases,
such as the use of local, that would otherwise be untested.
2021-04-10 17:56:39 -05:00
Bart Schaefer
408a830483 47913: implement CASE_PATHS option to make NO_CASE_GLOB more sensible 2021-04-10 14:26:46 -07:00
dana
1bec15a010 unposted: README: Document incompatibility caused by workers/43928 2021-04-10 16:16:26 -05:00
Bart Schaefer
e67ccd7f1e Add TYPESET_DOES_NOT_SET option (cf. 48469) 2021-04-10 14:13:02 -07:00
Bart Schaefer
13f85796ac unposted (cf. 48469): document oddness of ${emptystr[(i)]}. 2021-04-10 14:12:29 -07:00
Bart Schaefer
fd89e7cefa Change DECLAREDNULL to DEFAULTED 2021-04-10 14:12:29 -07:00
Bart Schaefer
d649bf78dc Fix ${(t)var} output, add comparative test cases 2021-04-10 14:12:29 -07:00
Bart Schaefer
2eb9289d12 Missed files from POSXIBUILTINS commit 2021-04-10 14:12:29 -07:00
Bart Schaefer
d4fa4c3689 Make DECLAREDNULL require POSIXBUILTINS and introduce a new test file.
V10private has been made agnostic to POSIXBUILTINS.
2021-04-10 14:12:29 -07:00
Bart Schaefer
b1bd99b67f Final repairs for declared state of tied arrays
Fixups still required in bin_typeset, but assignments to scalar work.
2021-04-10 14:12:29 -07:00
Bart Schaefer
fa5f59bf71 Additional tied-array cleanup when tied scalar had a previous value 2021-04-10 14:12:29 -07:00
Bart Schaefer
7a2d6589ba Unset of a tied local scalar previously left it using tiedarr_gsu 2021-04-10 14:12:29 -07:00
Bart Schaefer
128035c93c Partial fix for handling of tied arrays.
As of this commit when a tied array is declared but neither the scalar
nor the array has an initializer, the array is initialized to empty.

The scalar struct param of a tied pair stores a direct pointer to the
internal array value of the array struct param, and upon assignment
modifies it without referring to the containing struct.  This means
that there's no opportunity to clear the PM_DECLAREDNULL bits on both
structs when the scalar is assigned.  Conversely, assigning to the
array does use the struct for the scalar.
2021-04-10 14:12:29 -07:00
Bart Schaefer
a8f2a5d0c8 Choose a better bit-value for PM_DECLARED 2021-04-10 14:12:29 -07:00
Bart Schaefer
36886b5bac Add PM_DECLARED and PM_DECLAREDNULL parameter flags.
This addresses the issue that "typeset foo" creates $foo set to an
empty string, which differs from typeset handling in bash and ksh.
It does this by concealing the internal value rather than alter
the way internal values are defaulted.

This imposes the following changes:

A typeset variable with no assignment triggers NO_UNSET warnings
when the name is used in parameter expansion or math.

The typeset -AEFHLRTZailux options are applied upon the first
assignment to the variable.  Explicit unset before the first
assignment discards all of those properties.  If any option is
applied to an existing name, historic behavior is unchanged.

Consequent to the foregoing, the (t) parameter expansion flag
prints nothing until after the first assignment, and the (i)
and (I) subscript flags also print nothing.

The bash behavior of "unset foo; typeset -p foo" is NOT used.
This is called out as an emulation distinction, not a change.

The test cases have not been updated, so several now fail.
The test harness has been updated to declare default values.
2021-04-10 14:12:29 -07:00
dana
7269bc1ac4 48338: _git: Support case-insensitive path matching 2021-04-10 15:54:26 -05:00
Peter Stephenson
283d2f3c27 48432 and enable test: fix quotiing of zstyle -L for zstyle -e 2021-04-09 21:01:37 +01:00
Oliver Kiddle
eaff11c748 48378: complete compadd options for other completion functions 2021-04-09 21:53:41 +02:00
Oliver Kiddle
f3caff1536 48437: fix pid completion when cursor is in the middle of the line 2021-04-09 21:51:31 +02:00
Felipe Contreras
69ffb0bf0a 47786: prepare for autoconf 2.70 2021-04-09 21:49:14 +02:00
Felipe Contreras
df48cc8404 47785: remove deprecated autoconf functions
STDC_HEADERS and TIME_WITH_SYS_TIME are deprecated.
2021-04-09 21:45:11 +02:00
Jun-ichi Takimoto
62e86515e7 48416: update _gcore for macOS and GNU 2021-04-08 22:24:52 +09:00
Daniel Shahaf
e4a8740c78 48410: FAQ, METAFAQ: Mention zsh-security@. 2021-04-08 02:31:58 +00:00
Daniel Shahaf
4ba9008ec7 48379: Make the parameter expansion subscript flags parse error message, "error in flags", identify the location of the parse error. 2021-04-08 02:19:39 +00:00
Daniel Shahaf
295fbc0998 48321 (tweaked per thread): _perl_modules: Don't assume ${words[1]} to be either "perl" or "perldoc"
Also, correct an always-true condition guarding the fallback @INC
codepath.
2021-04-08 02:17:08 +00:00
Daniel Shahaf
608e49ac19 48425: Add an XFail test for a 'zstyle -L' escaping bug (workers/48424). 2021-04-07 17:45:57 +00:00