use \\builtin ipv \let] and \set internally

This commit is contained in:
tg 2017-03-19 20:59:29 +00:00
parent 73dca6e90f
commit 06b2d53ea2
6 changed files with 33 additions and 34 deletions

32
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.762 2017/03/19 20:36:04 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.763 2017/03/19 20:59:23 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -11091,7 +11091,7 @@ expected-stdout:
inline_TWHILE() {
i=1
while {
\let] " i < 10 "
\\builtin let " i < 10 "
}
do
echo $i
@ -11102,13 +11102,13 @@ expected-stdout:
i=1; while (( i < 10 )); do echo $i; let ++i; done
); }
function comsub_TWHILE {
x=$(i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done )
x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do echo $i ; let ++i ; done )
}
function reread_TWHILE { x=$((
i=1; while (( i < 10 )); do echo $i; let ++i; done
)|tr u x); }
function reread_TWHILE {
x=$(( i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x )
x=$(( i=1 ; while { \\builtin let " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x )
}
inline_TUNTIL() {
i=10; until (( !--i )) ; do echo $i; done
@ -11116,7 +11116,7 @@ expected-stdout:
inline_TUNTIL() {
i=10
until {
\let] " !--i "
\\builtin let " !--i "
}
do
echo $i
@ -11126,13 +11126,13 @@ expected-stdout:
i=10; until (( !--i )) ; do echo $i; done
); }
function comsub_TUNTIL {
x=$(i=10 ; until { \let] " !--i " ; } ; do echo $i ; done )
x=$(i=10 ; until { \\builtin let " !--i " ; } ; do echo $i ; done )
}
function reread_TUNTIL { x=$((
i=10; until (( !--i )) ; do echo $i; done
)|tr u x); }
function reread_TUNTIL {
x=$(( i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) | tr u x )
x=$(( i=10 ; until { \\builtin let " !--i " ; } ; do echo $i ; done ) | tr u x )
}
inline_TCOPROC() {
cat * |& ls
@ -11508,7 +11508,7 @@ expected-stdout:
case x in
(x)
a+=b
\set -A c+ -- d e
\\builtin set -A c+ -- d e
;;
esac
}
@ -11518,7 +11518,7 @@ expected-stdout:
esac
); }
function comsub_wdarrassign {
x=$(case x in (x) a+=b ; \set -A c+ -- d e ;; esac )
x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac )
}
function reread_wdarrassign { x=$((
case x in
@ -11526,7 +11526,7 @@ expected-stdout:
esac
)|tr u x); }
function reread_wdarrassign {
x=$(( case x in (x) a+=b ; \set -A c+ -- d e ;; esac ) | tr u x )
x=$(( case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) | tr u x )
}
---
name: comsub-torture-io
@ -11747,7 +11747,7 @@ expected-stdout:
inline_TWHILE() {
i=1
while {
\let] " i < 10 "
\\builtin let " i < 10 "
} >&3
do
echo $i
@ -11758,13 +11758,13 @@ expected-stdout:
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
); }
function comsub_TWHILE {
x=$(i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 )
x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 )
}
function reread_TWHILE { x=$((
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
)|tr u x); }
function reread_TWHILE {
x=$(( i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
x=$(( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
}
inline_TUNTIL() {
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
@ -11772,7 +11772,7 @@ expected-stdout:
inline_TUNTIL() {
i=10
until {
\let] " !--i "
\\builtin let " !--i "
} >&3
do
echo $i
@ -11782,13 +11782,13 @@ expected-stdout:
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
); }
function comsub_TUNTIL {
x=$(i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 )
x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do echo $i ; done >&3 )
}
function reread_TUNTIL { x=$((
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
)|tr u x); }
function reread_TUNTIL {
x=$(( i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x )
x=$(( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x )
}
inline_TCOPROC() {
cat * >&3 |& >&3 ls

View File

@ -1,5 +1,5 @@
# $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.111 2017/03/19 20:36:07 tg Exp $
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.112 2017/03/19 20:59:25 tg Exp $
#-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
@ -139,7 +139,7 @@ fi
# Z shell compatible chpwd() hook, used to update DIRSTACK[0]
DIRSTACKBASE=$(\\builtin realpath ~/. 2>/dev/null || \
\\builtin print -nr -- "${HOME:-/}")
set -A DIRSTACK
\\builtin set -A DIRSTACK
function chpwd {
DIRSTACK[0]=$(\\builtin realpath . 2>/dev/null || \
\\builtin print -nr -- "$PWD")
@ -441,7 +441,6 @@ function enable {
i_func[nfunc++]=jobs
i_func[nfunc++]=kill
i_func[nfunc++]=let
i_func[nfunc++]='let]' #XXX going
i_func[nfunc++]=print
i_func[nfunc++]=pwd
i_func[nfunc++]=read

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.329 2017/03/19 18:05:28 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.330 2017/03/19 20:59:25 tg Exp $");
#if HAVE_KILLPG
/*
@ -122,8 +122,6 @@ const struct builtin mkshbuiltins[] = {
{Tjobs, c_jobs},
{"kill", c_kill},
{"let", c_let},
/* deprecated, to be replaced by \\builtin let */
{"let]", c_let},
{"print", c_print},
{"pwd", c_pwd},
{Tread, c_read},

4
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.325 2017/03/19 20:36:07 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.326 2017/03/19 20:59:26 tg Exp $");
extern char **environ;
@ -257,7 +257,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
/* define built-in commands and see if we were called as one */
ktinit(APERM, &builtins,
/* currently up to 55 builtins: 75% of 128 = 2^7 */
/* currently up to 54 builtins: 75% of 128 = 2^7 */
7);
for (i = 0; mkshbuiltins[i].name != NULL; i++)
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,

10
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.432 2017/03/19 20:36:08 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.433 2017/03/19 20:59:27 tg Exp $
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -3742,12 +3742,8 @@ If an error occurs during
the parsing or evaluation of an expression, the exit status is greater than 1.
Since expressions may need to be quoted,
.No \&(( Ar expr No ))
is syntactic sugar for
.No "{ let '" Ns Ar expr Ns "'; }" .
.Pp
.It Ic let]
Internally used alias for
.Ic let .
is syntactic sugar for:
.Dl "{ \e\ebuiltin let '" Ns Ar expr Ns "'; }"
.Pp
.It Xo
.Ic mknod

12
syn.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.117 2017/03/12 02:04:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.118 2017/03/19 20:59:29 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -244,11 +244,15 @@ nested(int type, int smark, int emark)
return (block(type, t, NULL));
}
static const char builtin_cmd[] = {
QCHAR, '\\', CHAR, 'b', CHAR, 'u', CHAR, 'i',
CHAR, 'l', CHAR, 't', CHAR, 'i', CHAR, 'n', EOS
};
static const char let_cmd[] = {
QCHAR, 'l', CHAR, 'e', CHAR, 't', CHAR, ']', EOS
CHAR, 'l', CHAR, 'e', CHAR, 't', EOS
};
static const char setA_cmd0[] = {
QCHAR, 's', CHAR, 'e', CHAR, 't', EOS
CHAR, 's', CHAR, 'e', CHAR, 't', EOS
};
static const char setA_cmd1[] = {
CHAR, '-', CHAR, 'A', EOS
@ -342,6 +346,7 @@ get_command(int cf)
tcp[wdscan(tcp, EOS) - tcp - 3] = EOS;
/* construct new args strings */
XPput(args, wdcopy(builtin_cmd, ATEMP));
XPput(args, wdcopy(setA_cmd0, ATEMP));
XPput(args, wdcopy(setA_cmd1, ATEMP));
XPput(args, tcp);
@ -411,6 +416,7 @@ get_command(int cf)
}
t = newtp(TCOM);
t->lineno = lno;
XPput(args, wdcopy(builtin_cmd, ATEMP));
XPput(args, wdcopy(let_cmd, ATEMP));
XPput(args, yylval.cp);
break;