Module Name: src
Committed By: dsl
Date: Mon Dec 31 14:10:15 UTC 2012
Modified Files:
src/bin/sh: builtins.def exec.c jobs.c
Log Message:
Add support for '%n' being a shorthand for 'fg %n'.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/bin/sh/builtins.def
cvs rdiff -u -r1.43 -r1.44 src/bin/sh/exec.c
cvs rdiff -u -r1.70 -r1.71 src/bin/sh/jobs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/builtins.def
diff -u src/bin/sh/builtins.def:1.21 src/bin/sh/builtins.def:1.22
--- src/bin/sh/builtins.def:1.21 Tue Jul 13 15:05:59 2004
+++ src/bin/sh/builtins.def Mon Dec 31 14:10:15 2012
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: builtins.def,v 1.21 2004/07/13 15:05:59 seb Exp $
+# $NetBSD: builtins.def,v 1.22 2012/12/31 14:10:15 dsl Exp $
#
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
@@ -60,6 +60,7 @@ falsecmd -u false
histcmd -h -u fc
inputrc inputrc
fgcmd -j -u fg
+fgcmd_percent -j -u %
getoptscmd -u getopts
hashcmd hash
jobidcmd jobid
Index: src/bin/sh/exec.c
diff -u src/bin/sh/exec.c:1.43 src/bin/sh/exec.c:1.44
--- src/bin/sh/exec.c:1.43 Tue Mar 20 18:42:29 2012
+++ src/bin/sh/exec.c Mon Dec 31 14:10:15 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.43 2012/03/20 18:42:29 matt Exp $ */
+/* $NetBSD: exec.c,v 1.44 2012/12/31 14:10:15 dsl Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#else
-__RCSID("$NetBSD: exec.c,v 1.43 2012/03/20 18:42:29 matt Exp $");
+__RCSID("$NetBSD: exec.c,v 1.44 2012/12/31 14:10:15 dsl Exp $");
#endif
#endif /* not lint */
@@ -629,7 +629,8 @@ int
const struct builtincmd *bp;
for (bp = builtincmd ; bp->name ; bp++) {
- if (*bp->name == *name && equal(bp->name, name))
+ if (*bp->name == *name
+ && (*name == '%' || equal(bp->name, name)))
return bp->builtin;
}
return 0;
Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.70 src/bin/sh/jobs.c:1.71
--- src/bin/sh/jobs.c:1.70 Thu Feb 23 18:23:33 2012
+++ src/bin/sh/jobs.c Mon Dec 31 14:10:15 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.70 2012/02/23 18:23:33 joerg Exp $ */
+/* $NetBSD: jobs.c,v 1.71 2012/12/31 14:10:15 dsl Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: jobs.c,v 1.70 2012/02/23 18:23:33 joerg Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.71 2012/12/31 14:10:15 dsl Exp $");
#endif
#endif /* not lint */
@@ -249,15 +249,14 @@ SHELLPROC {
#if JOBS
-int
-fgcmd(int argc, char **argv)
+static int
+do_fgcmd(const char *arg_ptr)
{
struct job *jp;
int i;
int status;
- nextopt("");
- jp = getjob(*argptr, 0);
+ jp = getjob(arg_ptr, 0);
if (jp->jobctl == 0)
error("job not created under job control");
out1fmt("%s", jp->ps[0].cmd);
@@ -281,6 +280,20 @@ fgcmd(int argc, char **argv)
return status;
}
+int
+fgcmd(int argc, char **argv)
+{
+ nextopt("");
+ return do_fgcmd(*argptr);
+}
+
+int
+fgcmd_percent(int argc, char **argv)
+{
+ nextopt("");
+ return do_fgcmd(*argv);
+}
+
static void
set_curjob(struct job *jp, int mode)
{