Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2017-06-05 00:03:43 +0300
committerBryan Drewery <bryan@shatow.net>2017-06-05 00:03:43 +0300
commit2871803cdf07e1f9f8f1079a7d1bdc1130723457 (patch)
tree2d521b6fe54b8a41d29f3658652af954d2f374e9 /external
parent5a58c9f639e7b92e60283ff777b185ce8143786b (diff)
Update sh from FreeBSD head r319576
Diffstat (limited to 'external')
-rw-r--r--external/sh/builtins.def31
-rw-r--r--external/sh/eval.c10
-rwxr-xr-xexternal/sh/mkbuiltins46
3 files changed, 66 insertions, 21 deletions
diff --git a/external/sh/builtins.def b/external/sh/builtins.def
index 47014091..39cab135 100644
--- a/external/sh/builtins.def
+++ b/external/sh/builtins.def
@@ -32,7 +32,7 @@
# SUCH DAMAGE.
#
# @(#)builtins.def 8.4 (Berkeley) 5/4/95
-# $FreeBSD: head/bin/sh/builtins.def 314436 2017-02-28 23:42:47Z imp $
+# $FreeBSD: head/bin/sh/builtins.def 319576 2017-06-04 21:02:48Z bdrewery $
#
# This file lists all the builtin commands. The first column is the name
@@ -41,6 +41,9 @@
# without job control.
# The -h flag specifies that this command is to be excluded from systems
# based on the NO_HISTORY compile-time symbol.
+# The -n flag specifies that this command can safely be run in the same
+# process when it is the only command in a command substitution. Some
+# commands have special logic defined in safe_builtin().
# The -s flag specifies that this is a POSIX 'special built-in' command.
# The rest of the line specifies the command name or names used to run the
# command. The entry for bltincmd, which is run when the user does not specify
@@ -48,43 +51,43 @@
#
# NOTE: bltincmd must come first!
-bltincmd builtin
+bltincmd -n builtin
aliascmd alias
bgcmd -j bg
bindcmd bind
breakcmd -s break -s continue
cdcmd cd chdir
-commandcmd command
+commandcmd -n command
dotcmd -s .
-echocmd echo
+echocmd -n echo
evalcmd -s eval
execcmd -s exec
exitcmd -s exit
letcmd let
exportcmd -s export -s readonly
#exprcmd expr
-falsecmd false
+falsecmd -n false
fgcmd -j fg
freebsd_wordexpcmd freebsd_wordexp
getoptscmd getopts
hashcmd hash
histcmd -h fc
-jobidcmd jobid
-jobscmd jobs
-killcmd kill
+jobidcmd -n jobid
+jobscmd -n jobs
+killcmd -n kill
localcmd local
-printfcmd printf
-pwdcmd pwd
+printfcmd -n printf
+pwdcmd -n pwd
readcmd read
returncmd -s return
setcmd -s set
setvarcmd setvar
shiftcmd -s shift
-testcmd test [
-timescmd -s times
+testcmd -n test [
+timescmd -n -s times
trapcmd -s trap
-truecmd -s : true
-typecmd type
+truecmd -n -s : true
+typecmd -n type
ulimitcmd ulimit
umaskcmd umask
unaliascmd unalias
diff --git a/external/sh/eval.c b/external/sh/eval.c
index c7e8b17e..459c17e5 100644
--- a/external/sh/eval.c
+++ b/external/sh/eval.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/eval.c 318501 2017-05-18 21:44:14Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/eval.c 319576 2017-06-04 21:02:48Z bdrewery $");
#include <paths.h>
#include <signal.h>
@@ -470,6 +470,7 @@ evalredir(union node *n, int flags)
if (e == EXERROR || e == EXEXEC) {
if (in_redirect) {
exitstatus = 2;
+ FORCEINTON;
return;
}
}
@@ -799,11 +800,8 @@ xtracecommand(struct arglist *varlist, int argc, char **argv)
static int
safe_builtin(int idx, int argc, char **argv)
{
- if (idx == BLTINCMD || idx == COMMANDCMD || idx == ECHOCMD ||
- idx == FALSECMD || idx == JOBIDCMD || idx == JOBSCMD ||
- idx == KILLCMD || idx == PRINTFCMD || idx == PWDCMD ||
- idx == TESTCMD || idx == TIMESCMD || idx == TRUECMD ||
- idx == TYPECMD)
+ /* Generated from builtins.def. */
+ if (safe_builtin_always(idx))
return (1);
if (idx == EXPORTCMD || idx == TRAPCMD || idx == ULIMITCMD ||
idx == UMASKCMD)
diff --git a/external/sh/mkbuiltins b/external/sh/mkbuiltins
index ea294b75..799be589 100755
--- a/external/sh/mkbuiltins
+++ b/external/sh/mkbuiltins
@@ -32,7 +32,7 @@
# SUCH DAMAGE.
#
# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
-# $FreeBSD: head/bin/sh/mkbuiltins 314436 2017-02-28 23:42:47Z imp $
+# $FreeBSD: head/bin/sh/mkbuiltins 319576 2017-06-04 21:02:48Z bdrewery $
temp=`/usr/bin/mktemp -t ka`
havehist=1
@@ -66,6 +66,9 @@ const unsigned char builtincmd[] = {'
awk '{ for (i = 2 ; i <= NF ; i++) {
if ($i == "-s") {
spc = 1;
+ } else if ($i == "-n") {
+ # Handled later for builtins.h
+ continue
} else {
printf "\t\"\\%03o\\%03o%s\"\n", length($i), (spc ? 128 : 0) + NR-1, $i
spc = 0;
@@ -90,4 +93,45 @@ extern int (*const builtinfunc[])(int, char **);
extern const unsigned char builtincmd[];
'
awk '{ printf "int %s(int, char **);\n", $1}' $temp
+
+# Build safe_builtin_always()
+cat <<EOF
+
+static inline int
+safe_builtin_always(int idx)
+{
+EOF
+awk '
+BEGIN { printed = 0 }
+{
+ for (i = 2 ; i <= NF ; i++) {
+ if ($i == "-s") {
+ continue
+ } else if ($i == "-n") {
+ nofork = 1;
+ } else {
+ if (nofork == 0) {
+ continue
+ }
+ if (printed == 1) {
+ printf " || \n\t "
+ } else {
+ printf "\tif ("
+ }
+ printf "idx == " toupper($1)
+ printed = 1
+ nofork = 0;
+ # Only need to check each once
+ break
+ }
+ }
+}' $temp
+
+cat << EOF
+)
+ return (1);
+ return(0);
+}
+EOF
+
rm -f $temp