Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh Add support for '%n' being a shorthand for 'fg %n'.
details: https://anonhg.NetBSD.org/src/rev/cb85780d6bea
branches: trunk
changeset: 783606:cb85780d6bea
user: dsl <dsl%NetBSD.org@localhost>
date: Mon Dec 31 14:10:15 2012 +0000
description:
Add support for '%n' being a shorthand for 'fg %n'.
diffstat:
bin/sh/builtins.def | 3 ++-
bin/sh/exec.c | 7 ++++---
bin/sh/jobs.c | 25 +++++++++++++++++++------
3 files changed, 25 insertions(+), 10 deletions(-)
diffs (104 lines):
diff -r 0537d8da04a1 -r cb85780d6bea bin/sh/builtins.def
--- a/bin/sh/builtins.def Mon Dec 31 13:28:30 2012 +0000
+++ b/bin/sh/builtins.def Mon Dec 31 14:10:15 2012 +0000
@@ -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 @@
histcmd -h -u fc
inputrc inputrc
fgcmd -j -u fg
+fgcmd_percent -j -u %
getoptscmd -u getopts
hashcmd hash
jobidcmd jobid
diff -r 0537d8da04a1 -r cb85780d6bea bin/sh/exec.c
--- a/bin/sh/exec.c Mon Dec 31 13:28:30 2012 +0000
+++ b/bin/sh/exec.c Mon Dec 31 14:10:15 2012 +0000
@@ -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 @@
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;
diff -r 0537d8da04a1 -r cb85780d6bea bin/sh/jobs.c
--- a/bin/sh/jobs.c Mon Dec 31 13:28:30 2012 +0000
+++ b/bin/sh/jobs.c Mon Dec 31 14:10:15 2012 +0000
@@ -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 @@
#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 @@
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)
{
Home |
Main Index |
Thread Index |
Old Index