use \\builtin ipv \let] and \set internally
This commit is contained in:
32
check.t
32
check.t
@ -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 -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -11091,7 +11091,7 @@ expected-stdout:
|
|||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TIF_TBANG_TDBRACKET_TELIF {
|
function reread_TIF_TBANG_TDBRACKET_TELIF {
|
||||||
x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
|
x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TWHILE() {
|
inline_TWHILE() {
|
||||||
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
||||||
}
|
}
|
||||||
@ -11102,13 +11102,13 @@ expected-stdout:
|
|||||||
}
|
}
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
let ++i
|
let ++i
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
function comsub_TWHILE { x=$(
|
function comsub_TWHILE { x=$(
|
||||||
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
i=1; while (( i < 10 )); do echo $i; let ++i; done
|
||||||
); }
|
); }
|
||||||
function comsub_TWHILE {
|
function comsub_TWHILE {
|
||||||
x=$(i=1 ; while { \\builtin 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=$((
|
function reread_TWHILE { x=$((
|
||||||
@ -11116,7 +11116,7 @@ expected-stdout:
|
|||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TWHILE {
|
function reread_TWHILE {
|
||||||
x=$(( i=1 ; while { \\builtin 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() {
|
inline_TUNTIL() {
|
||||||
i=10; until (( !--i )) ; do echo $i; done
|
i=10; until (( !--i )) ; do echo $i; done
|
||||||
}
|
}
|
||||||
@ -11126,13 +11126,13 @@ expected-stdout:
|
|||||||
\\builtin let " !--i "
|
\\builtin let " !--i "
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
function comsub_TUNTIL { x=$(
|
function comsub_TUNTIL { x=$(
|
||||||
i=10; until (( !--i )) ; do echo $i; done
|
i=10; until (( !--i )) ; do echo $i; done
|
||||||
); }
|
); }
|
||||||
function comsub_TUNTIL {
|
function comsub_TUNTIL {
|
||||||
x=$(i=10 ; until { \\builtin let " !--i " ; } ; do echo $i ; done )
|
x=$(i=10 ; until { \\builtin let " !--i " ; } ; do echo $i ; done )
|
||||||
}
|
}
|
||||||
function reread_TUNTIL { x=$((
|
function reread_TUNTIL { x=$((
|
||||||
@ -11508,7 +11508,7 @@ expected-stdout:
|
|||||||
}
|
}
|
||||||
inline_wdarrassign() {
|
inline_wdarrassign() {
|
||||||
case x in
|
case x in
|
||||||
x) a+=b; c+=(d e)
|
x) a+=b; c+=(d e)
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
inline_wdarrassign() {
|
inline_wdarrassign() {
|
||||||
@ -11518,7 +11518,7 @@ expected-stdout:
|
|||||||
\\builtin set -A c+ -- d e
|
\\builtin set -A c+ -- d e
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
function comsub_wdarrassign { x=$(
|
function comsub_wdarrassign { x=$(
|
||||||
case x in
|
case x in
|
||||||
x) a+=b; c+=(d e)
|
x) a+=b; c+=(d e)
|
||||||
@ -11526,7 +11526,7 @@ expected-stdout:
|
|||||||
); }
|
); }
|
||||||
function comsub_wdarrassign {
|
function comsub_wdarrassign {
|
||||||
x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac )
|
x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac )
|
||||||
}
|
}
|
||||||
function reread_wdarrassign { x=$((
|
function reread_wdarrassign { x=$((
|
||||||
case x in
|
case x in
|
||||||
x) a+=b; c+=(d e)
|
x) a+=b; c+=(d e)
|
||||||
@ -11747,7 +11747,7 @@ expected-stdout:
|
|||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TIF_TBANG_TDBRACKET_TELIF {
|
function reread_TIF_TBANG_TDBRACKET_TELIF {
|
||||||
x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
|
x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
|
||||||
}
|
}
|
||||||
inline_TWHILE() {
|
inline_TWHILE() {
|
||||||
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
||||||
}
|
}
|
||||||
@ -11758,13 +11758,13 @@ expected-stdout:
|
|||||||
} >&3
|
} >&3
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
let ++i
|
let ++i
|
||||||
done >&3
|
done >&3
|
||||||
}
|
}
|
||||||
function comsub_TWHILE { x=$(
|
function comsub_TWHILE { x=$(
|
||||||
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
|
||||||
); }
|
); }
|
||||||
function comsub_TWHILE {
|
function comsub_TWHILE {
|
||||||
x=$(i=1 ; while { \\builtin 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=$((
|
function reread_TWHILE { x=$((
|
||||||
@ -11772,7 +11772,7 @@ expected-stdout:
|
|||||||
)|tr u x); }
|
)|tr u x); }
|
||||||
function reread_TWHILE {
|
function reread_TWHILE {
|
||||||
x=$(( i=1 ; while { \\builtin 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() {
|
inline_TUNTIL() {
|
||||||
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
||||||
}
|
}
|
||||||
@ -11782,13 +11782,13 @@ expected-stdout:
|
|||||||
\\builtin let " !--i "
|
\\builtin let " !--i "
|
||||||
} >&3
|
} >&3
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
done >&3
|
done >&3
|
||||||
}
|
}
|
||||||
function comsub_TUNTIL { x=$(
|
function comsub_TUNTIL { x=$(
|
||||||
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
i=10; until (( !--i )) >&3 ; do echo $i; done >&3
|
||||||
); }
|
); }
|
||||||
function comsub_TUNTIL {
|
function comsub_TUNTIL {
|
||||||
x=$(i=10 ; until { \\builtin 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=$((
|
function reread_TUNTIL { x=$((
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# $Id$
|
# $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,
|
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
# 2011, 2012, 2013, 2014, 2015, 2016, 2017
|
||||||
@ -139,7 +139,7 @@ fi
|
|||||||
# Z shell compatible chpwd() hook, used to update DIRSTACK[0]
|
# Z shell compatible chpwd() hook, used to update DIRSTACK[0]
|
||||||
DIRSTACKBASE=$(\\builtin realpath ~/. 2>/dev/null || \
|
DIRSTACKBASE=$(\\builtin realpath ~/. 2>/dev/null || \
|
||||||
\\builtin print -nr -- "${HOME:-/}")
|
\\builtin print -nr -- "${HOME:-/}")
|
||||||
set -A DIRSTACK
|
\\builtin set -A DIRSTACK
|
||||||
function chpwd {
|
function chpwd {
|
||||||
DIRSTACK[0]=$(\\builtin realpath . 2>/dev/null || \
|
DIRSTACK[0]=$(\\builtin realpath . 2>/dev/null || \
|
||||||
\\builtin print -nr -- "$PWD")
|
\\builtin print -nr -- "$PWD")
|
||||||
@ -441,7 +441,6 @@ function enable {
|
|||||||
i_func[nfunc++]=jobs
|
i_func[nfunc++]=jobs
|
||||||
i_func[nfunc++]=kill
|
i_func[nfunc++]=kill
|
||||||
i_func[nfunc++]=let
|
i_func[nfunc++]=let
|
||||||
i_func[nfunc++]='let]' #XXX going
|
|
||||||
i_func[nfunc++]=print
|
i_func[nfunc++]=print
|
||||||
i_func[nfunc++]=pwd
|
i_func[nfunc++]=pwd
|
||||||
i_func[nfunc++]=read
|
i_func[nfunc++]=read
|
||||||
|
4
funcs.c
4
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#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
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -122,8 +122,6 @@ const struct builtin mkshbuiltins[] = {
|
|||||||
{Tjobs, c_jobs},
|
{Tjobs, c_jobs},
|
||||||
{"kill", c_kill},
|
{"kill", c_kill},
|
||||||
{"let", c_let},
|
{"let", c_let},
|
||||||
/* deprecated, to be replaced by \\builtin let */
|
|
||||||
{"let]", c_let},
|
|
||||||
{"print", c_print},
|
{"print", c_print},
|
||||||
{"pwd", c_pwd},
|
{"pwd", c_pwd},
|
||||||
{Tread, c_read},
|
{Tread, c_read},
|
||||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#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;
|
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 */
|
/* define built-in commands and see if we were called as one */
|
||||||
ktinit(APERM, &builtins,
|
ktinit(APERM, &builtins,
|
||||||
/* currently up to 55 builtins: 75% of 128 = 2^7 */
|
/* currently up to 54 builtins: 75% of 128 = 2^7 */
|
||||||
7);
|
7);
|
||||||
for (i = 0; mkshbuiltins[i].name != NULL; i++)
|
for (i = 0; mkshbuiltins[i].name != NULL; i++)
|
||||||
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
|
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
|
||||||
|
10
mksh.1
10
mksh.1
@ -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 $
|
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" 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.
|
the parsing or evaluation of an expression, the exit status is greater than 1.
|
||||||
Since expressions may need to be quoted,
|
Since expressions may need to be quoted,
|
||||||
.No \&(( Ar expr No ))
|
.No \&(( Ar expr No ))
|
||||||
is syntactic sugar for
|
is syntactic sugar for:
|
||||||
.No "{ let '" Ns Ar expr Ns "'; }" .
|
.Dl "{ \e\ebuiltin let '" Ns Ar expr Ns "'; }"
|
||||||
.Pp
|
|
||||||
.It Ic let]
|
|
||||||
Internally used alias for
|
|
||||||
.Ic let .
|
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic mknod
|
.Ic mknod
|
||||||
|
12
syn.c
12
syn.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#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 {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
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));
|
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[] = {
|
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[] = {
|
static const char setA_cmd0[] = {
|
||||||
QCHAR, 's', CHAR, 'e', CHAR, 't', EOS
|
CHAR, 's', CHAR, 'e', CHAR, 't', EOS
|
||||||
};
|
};
|
||||||
static const char setA_cmd1[] = {
|
static const char setA_cmd1[] = {
|
||||||
CHAR, '-', CHAR, 'A', EOS
|
CHAR, '-', CHAR, 'A', EOS
|
||||||
@ -342,6 +346,7 @@ get_command(int cf)
|
|||||||
tcp[wdscan(tcp, EOS) - tcp - 3] = EOS;
|
tcp[wdscan(tcp, EOS) - tcp - 3] = EOS;
|
||||||
|
|
||||||
/* construct new args strings */
|
/* construct new args strings */
|
||||||
|
XPput(args, wdcopy(builtin_cmd, ATEMP));
|
||||||
XPput(args, wdcopy(setA_cmd0, ATEMP));
|
XPput(args, wdcopy(setA_cmd0, ATEMP));
|
||||||
XPput(args, wdcopy(setA_cmd1, ATEMP));
|
XPput(args, wdcopy(setA_cmd1, ATEMP));
|
||||||
XPput(args, tcp);
|
XPput(args, tcp);
|
||||||
@ -411,6 +416,7 @@ get_command(int cf)
|
|||||||
}
|
}
|
||||||
t = newtp(TCOM);
|
t = newtp(TCOM);
|
||||||
t->lineno = lno;
|
t->lineno = lno;
|
||||||
|
XPput(args, wdcopy(builtin_cmd, ATEMP));
|
||||||
XPput(args, wdcopy(let_cmd, ATEMP));
|
XPput(args, wdcopy(let_cmd, ATEMP));
|
||||||
XPput(args, yylval.cp);
|
XPput(args, yylval.cp);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user