From: Felix Rosencrantz <f_rosencrantz@yahoo.com>
To: zsh-workers <zsh-workers@sunsite.auc.dk>
Subject: PATCH: Add jobdirs association to parameter module (again)
Date: Sun, 12 Dec 1999 22:47:26 -0800 (PST) [thread overview]
Message-ID: <19991213064726.7390.qmail@web1306.mail.yahoo.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 812 bytes --]
(Sorry, the patch got messed up, I'll try it as an attachment.)
This proposed patch adds a new association to the parameter module
called jobdirs. This provides an association with job numbers and the
directories in which the jobs were started.
I decided to use the name jobdirs instead of jobpwds since the "jobs"
builtin uses the "-d" to list these directories. Though I could see
that jobpwds might also be appropriate.
It is possible to use the "jobs -d" command to get this same
information with a little processing. Though adding an association
seems to be a cleaner way for zsh functions or scripts to get this
information.
-FR
__________________________________________________
Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one place.
Yahoo! Shopping: http://shopping.yahoo.com
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3692 bytes --]
--- old/Src/Modules/parameter.c Mon Dec 6 02:26:32 1999
+++ Src/Modules/parameter.c Sun Dec 12 20:58:25 1999
@@ -1325,6 +1325,83 @@
}
}
+/* Functions for the jobdirs special parameter. */
+
+/**/
+static char *
+pmjobdir(int job)
+{
+ char *ret;
+
+ ret = dupstring(jobtab[job].pwd);
+ return ret;
+}
+
+/**/
+static HashNode
+getpmjobdir(HashTable ht, char *name)
+{
+ Param pm = NULL;
+ int job;
+
+ HEAPALLOC {
+ pm = (Param) zhalloc(sizeof(struct param));
+ pm->nam = dupstring(name);
+ pm->flags = PM_SCALAR | PM_READONLY;
+ pm->sets.cfn = NULL;
+ pm->gets.cfn = strgetfn;
+ pm->unsetfn = NULL;
+ pm->ct = 0;
+ pm->env = NULL;
+ pm->ename = NULL;
+ pm->old = NULL;
+ pm->level = 0;
+
+ if ((job = atoi(name)) >= 1 && job < MAXJOB &&
+ jobtab[job].stat && jobtab[job].procs &&
+ !(jobtab[job].stat & STAT_NOPRINT))
+ pm->u.str = pmjobdir(job);
+ else {
+ pm->u.str = dupstring("");
+ pm->flags |= PM_UNSET;
+ }
+ } LASTALLOC;
+
+ return (HashNode) pm;
+}
+
+/**/
+static void
+scanpmjobdirs(HashTable ht, ScanFunc func, int flags)
+{
+ struct param pm;
+ int job;
+ char buf[40];
+
+ pm.flags = PM_SCALAR | PM_READONLY;
+ pm.sets.cfn = NULL;
+ pm.gets.cfn = strgetfn;
+ pm.unsetfn = NULL;
+ pm.ct = 0;
+ pm.env = NULL;
+ pm.ename = NULL;
+ pm.old = NULL;
+ pm.level = 0;
+
+ for (job = 1; job < MAXJOB; job++) {
+ if (jobtab[job].stat && jobtab[job].procs &&
+ !(jobtab[job].stat & STAT_NOPRINT)) {
+ sprintf(buf, "%d", job);
+ pm.nam = dupstring(buf);
+ if (func != scancountparams &&
+ ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
+ !(flags & SCANPM_WANTKEYS)))
+ pm.u.str = pmjobdir(job);
+ func((HashNode) &pm, flags);
+ }
+ }
+}
+
/* Functions for the nameddirs special parameter. */
/**/
@@ -1833,6 +1910,9 @@
{ "jobstates", PM_READONLY,
getpmjobstate, scanpmjobstates, hashsetfn,
NULL, NULL, stdunsetfn, NULL },
+ { "jobdirs", PM_READONLY,
+ getpmjobdir, scanpmjobdirs, hashsetfn,
+ NULL, NULL, stdunsetfn, NULL },
{ "nameddirs", 0,
getpmnameddir, scanpmnameddirs, setpmnameddirs,
NULL, NULL, stdunsetfn, NULL },
@@ -1889,8 +1969,7 @@
if (def->hsetfn)
def->pm->sets.hfn = def->hsetfn;
} else {
- if (!(def->pm = createparam(def->name, def->flags | PM_HIDE |
- PM_REMOVABLE)))
+ if (!(def->pm = createparam(def->name, def->flags | PM_HIDE)))
return 1;
def->pm->sets.afn = def->setfn;
def->pm->gets.afn = def->getfn;
--- old/Src/Modules/parameter.mdd Wed Nov 3 03:07:27 1999
+++ Src/Modules/parameter.mdd Fri Dec 10 11:34:25 1999
@@ -1,3 +1,3 @@
-autoparams="parameters commands functions dis_functions funcstack builtins dis_builtins reswords dis_reswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs aliases dis_aliases galiases dis_galiases"
+autoparams="parameters commands functions dis_functions funcstack builtins dis_builtins reswords dis_reswords options modules dirstack history historywords jobtexts jobdirs jobstates nameddirs userdirs aliases dis_aliases galiases dis_galiases"
objects="parameter.o"
--- old/zsh/Doc/Zsh/mod_parameter.yo Wed Nov 3 03:07:19 1999
+++ Doc/Zsh/mod_parameter.yo Fri Dec 10 11:32:09 1999
@@ -110,6 +110,10 @@
item(tt(historywords))(
A special array containing the words stored in the history.
)
+vindex(jobdirs)
+item(tt(jobdirs))(
+This association maps job numbers to the directories from which the job was started (which may not be the current directory of the job).
+)
vindex(jobtexts)
item(tt(jobtexts))(
This association maps job numbers to the texts of the command lines
reply other threads:[~1999-12-13 6:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=19991213064726.7390.qmail@web1306.mail.yahoo.com \
--to=f_rosencrantz@yahoo.com \
--cc=zsh-workers@sunsite.auc.dk \
/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).