zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers <zsh-workers@zsh.org>
Subject: Re: [Bug] $jobstates does not work in $()
Date: Wed, 02 Mar 2022 20:18:41 +0000	[thread overview]
Message-ID: <ac5c19d9717be49ea3aed6d3c6c90634ab6c3902.camel@ntlworld.com> (raw)
In-Reply-To: <18fc86e5-467d-4753-9f82-6a3073874334@www.fastmail.com>

On Wed, 2022-03-02 at 09:44 +0000, Daniel Shahaf wrote:
> Peter Stephenson wrote on Tue, 01 Mar 2022 10:40 +00:00:
> Is this testable?  Sorry, haven't got time to write a test myself right now.

We could do something like this.

pws

diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index b09f2ac62..d52888dd9 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -144,12 +144,14 @@
   zpty_start
   zpty_input 'sleep 3 &'
   zpty_input 'jobs -r'
+  zpty_input '(jobs -r)'
   zpty_input 'print -- -'
   zpty_input 'jobs -s'
   zpty_stop
 0:`jobs -r` and `jobs -s` with running job
 *>\[1] [0-9]##
 *>\[1]  + running*sleep*
+*>\[1]  + running*sleep*
 *>-
 *>zsh:*SIGHUPed*
 
diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst
new file mode 100644
index 000000000..474adfaec
--- /dev/null
+++ b/Test/W03jobparameters.ztst
@@ -0,0 +1,49 @@
+# Tests for interactive job control with parameter state
+
+%prep
+
+  if zmodload zsh/zpty 2> /dev/null; then
+    zpty_start() {
+      export PS1= PS2=
+      zpty -d
+      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+    }
+    zpty_input() {
+      zpty -w zsh "${(F)@}" $'\n'
+    }
+    zpty_line() {
+      local REPLY
+      integer i
+      for (( i = 0; i < ${1:-1}; ++i )); do
+        zpty -r zsh REPLY
+        print -r -- ${REPLY%%($'\r\n'|$'\n')}
+      done
+    }
+    zpty_stop() {
+      # exit twice in case of check_jobs
+      zpty -w zsh $'exit\nexit\n'
+      # zpty gives no output when piped without these braces (?)
+      { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
+      zpty -d
+      :
+    }
+    if ! zmodload zsh/parameter 2> /dev/null; then
+      ZTST_unimplemented='the zsh/parameter module is not available'
+    fi
+  else
+    ZTST_unimplemented='the zsh/zpty module is not available'
+  fi
+
+%test
+
+  zpty_start
+  zpty_input 'sleep 3 &'
+  zpty_input 'print $jobstates'
+  zpty_input '(print $jobstates)'
+  zpty_input 'jobs -s'
+  zpty_stop
+0:$jobstate for running job in main shell and subshell
+*>\[1] [0-9]##
+*>running:+:*=running
+*>running:+:*=running
+*>zsh:*SIGHUPed*



  reply	other threads:[~2022-03-02 20:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  0:46 Carl Agrell
2022-03-01 10:40 ` Peter Stephenson
2022-03-02  9:44   ` Daniel Shahaf
2022-03-02 20:18     ` Peter Stephenson [this message]
2022-03-03 22:04       ` Vin Shelton
2022-03-03 23:07         ` Bart Schaefer
2022-03-04  2:14           ` Jun T
2022-03-04 13:04             ` Daniel Shahaf
2022-03-04 13:13               ` Vin Shelton
2022-03-06  4:18               ` Jun T
2022-03-07 14:22                 ` Daniel Shahaf

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=ac5c19d9717be49ea3aed6d3c6c90634ab6c3902.camel@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --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).