zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: zsh-workers@zsh.org
Subject: [PATCHv2 1/2] [long] improvements to limit/ulimit API and doc ((un)limit in csh emulation)
Date: Thu, 26 Nov 2020 06:57:19 +0000	[thread overview]
Message-ID: <20201126065719.mqaljeb3cwd7k2k4@chazelas.org> (raw)
In-Reply-To: <20201125003512.GC17978@tarpaulin.shahaf.local2>

2020-11-25 00:35:12 +0000, Daniel Shahaf:
[...]
> Could you please split this into one patch per logical change?  That
> would make it easier to review, both now, and in the future should
> a regression be bisected to it.
[...]

Here is for the csh builtins, I'll send a second one for the
rest addressing Oliver's comments (doc, testcase, _ulimit)
hopefully tonight. I'll add a test case to verify we get errors
upon unexpected suffixes as well.

From: Stephane Chazelas <stephane@chazelas.org>
Date: Thu, 26 Nov 2020 06:34:44 +0000
Subject: [PATCH] Re-enable `limit` and `unlimit` in csh emulation.

Those two builtins do come from csh (4BSD, 1980 along with resource
limits) in the first place, they were disabled when emulating *other*
shells, that should only have been for POSIX/ksh which have ulimit and
not limit.

  -> changed the features_emu in rlimits.mdd (only used there) and
    mkbltnmlst.sh to features_posix for those to only be disabled
    in sh/ksh emulation.
---
 Doc/Zsh/builtins.yo      |  4 ++--
 NEWS                     |  2 ++
 Src/Builtins/rlimits.mdd |  8 +++++++-
 Src/mkbltnmlst.sh        | 10 +++++-----
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index ebb29f632..2f1ccd8a5 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1180,7 +1180,7 @@ sitem([var(mm)tt(:)]var(ss))(minutes and seconds)
 endsitem()
 
 The tt(limit) command is not made available by default when the
-shell starts in a mode emulating another shell.  It can be made available
+shell starts in sh or ksh emulation mode.  It can be made available
 with the command `tt(zmodload -F zsh/rlimits b:limit)'.
 )
 findex(local)
@@ -2343,7 +2343,7 @@ The resources of the shell process are only changed if the tt(-s)
 flag is given.
 
 The tt(unlimit) command is not made available by default when the
-shell starts in a mode emulating another shell.  It can be made available
+shell starts in sh or ksh emulation mode.  It can be made available
 with the command `tt(zmodload -F zsh/rlimits b:unlimit)'.
 )
 findex(unset)
diff --git a/NEWS b/NEWS
index a8e7df80e..d05e8b64f 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ The zsh/system module's `zsystem flock` command learnt an -i option to
 set the wait interval used with -t. Additionally, -t now supports
 fractional seconds.
 
+The `limit` and `unlimit` builtins are now available again in csh emulation.
+
 Changes from 5.7.1-test-3 to 5.8
 --------------------------------
 
diff --git a/Src/Builtins/rlimits.mdd b/Src/Builtins/rlimits.mdd
index 06c9e9c7f..248a03e61 100644
--- a/Src/Builtins/rlimits.mdd
+++ b/Src/Builtins/rlimits.mdd
@@ -3,6 +3,12 @@ link=either
 load=yes
 
 autofeatures="b:limit b:ulimit b:unlimit"
-autofeatures_emu="b:ulimit"
+
+# limit is the csh builtin, while ulimit is the ksh/posix one.
+# Autoloading ulimit in csh emulation should be relatively
+# harmless as "ulimit" contrary to "limit" is not otherwise
+# a common English word. So we're only accomodating sh/ksh
+# emulations.
+autofeatures_posix="b:ulimit"
 
 objects="rlimits.o"
diff --git a/Src/mkbltnmlst.sh b/Src/mkbltnmlst.sh
index c4611d8b3..7ebc2a751 100644
--- a/Src/mkbltnmlst.sh
+++ b/Src/mkbltnmlst.sh
@@ -37,10 +37,10 @@ for x_mod in $x_mods; do
         echo "/* non-linked-in known module \`$x_mod' */"
 	linked=no
     esac
-    unset moddeps autofeatures autofeatures_emu
+    unset moddeps autofeatures autofeatures_posix
     . $srcdir/../$modfile
     if test "x$autofeatures" != x; then
-        if test "x$autofeatures_emu" != x; then
+        if test "x$autofeatures_posix" != x; then
             echo "  {"
 	    echo "    char *zsh_features[] = { "
 	    for feature in $autofeatures; do
@@ -48,14 +48,14 @@ for x_mod in $x_mods; do
 	    done
 	    echo "      NULL"
 	    echo "    }; "
-	    echo "    char *emu_features[] = { "
-	    for feature in $autofeatures_emu; do
+	    echo "    char *posix_features[] = { "
+	    for feature in $autofeatures_posix; do
 		echo "      \"$feature\","
 	    done
 	    echo "      NULL"
 	    echo "    }; "
 	    echo "    autofeatures(\"zsh\", \"$x_mod\","
-	    echo "       EMULATION(EMULATE_ZSH) ? zsh_features : emu_features,"
+	    echo "       EMULATION(EMULATE_KSH|EMULATE_SH) ? posix_features : zsh_features,"
 	    echo "       0, 1);"
 	    echo "  }"
         else
-- 
2.25.1




  parent reply	other threads:[~2020-11-26  6:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 21:49 [PATCHv1] [long] improvements to limit/ulimit API and doc Stephane Chazelas
2020-11-25  0:35 ` Daniel Shahaf
2020-11-25  6:44   ` Stephane Chazelas
2020-11-27 17:16     ` Daniel Shahaf
2020-11-26  6:57   ` Stephane Chazelas [this message]
2020-11-25 23:43 ` Oliver Kiddle
2020-11-26 20:14   ` [PATCH] ulimit option completions using ulimit -a output Stephane Chazelas
2020-11-27  7:13     ` Stephane Chazelas
2020-11-27  8:15       ` Felipe Contreras
2020-11-27 12:19       ` Oliver Kiddle
2021-03-27 21:25         ` Lawrence Velázquez
2021-04-03 14:57           ` Lawrence Velázquez
2021-04-10 20:11             ` Lawrence Velázquez
2021-04-13 14:35     ` Daniel Shahaf
2021-05-09 20:37       ` Lawrence Velázquez
2021-05-11 19:05         ` Stephane Chazelas
2020-11-26 20:58   ` [PATCHv2 2/2] [long] improvements to limit/ulimit API and doc (the rest) Stephane Chazelas
2020-11-27 16:39     ` Daniel Shahaf
2020-11-27 20:13       ` Stephane Chazelas
2020-11-27 20:36         ` Daniel Shahaf
2020-11-28  6:52           ` zsh coding style (was about a limit patch review) Stephane Chazelas
2020-12-01 16:47             ` Daniel Shahaf
2020-11-28  8:16         ` [PATCHv3 2/2] [long] improvements to limit/ulimit API and doc (the rest) Stephane Chazelas
2021-03-27 21:21           ` Lawrence Velázquez
2021-03-31 18:06             ` Stephane Chazelas
2020-11-26 11:19 ` [PATCHv1] [long] improvements to limit/ulimit API and doc Jun T
2020-11-26 13:55   ` Stephane Chazelas
2020-11-26 15:22     ` Jun. T
2020-11-26 17:23       ` Stephane Chazelas
2020-11-27 18:24         ` Jun. T
2020-11-27 18:34           ` Daniel Shahaf
2020-11-27 20:46           ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201126065719.mqaljeb3cwd7k2k4@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).