blob: fa6559f3913604d7276322d948adfb2eb7456bf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1990-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* http://www.eclipse.org/org/documents/epl-v10.html *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* coshell readonly data
*/
#include "colib.h"
char coident[] = "\
# @(#)$Id: libcoshell (AT&T Research) 2012-02-22 $\n\
%s=%d\n\
{ { (eval 'function fun { trap \":\" 0; return 1; }; trap \"exit 0\" 0; fun; exit 1') && PATH= print -u$%s ksh; } || { times && echo bsh >&$%s; } || { echo osh >&$%s; }; } >/dev/null 2>&1\n\
";
char cobinit[] = "\
if (eval 'f() echo') >/dev/null 2>&1\n\
then eval 'ignore() {\n\
case $- in\n\
*x*) set -\n\
_coshell_silent=\n\
;;\n\
*) _coshell_silent=1\n\
;;\n\
esac\n\
_coshell_state=exp\n\
_coshell_stop=\"<< -- StoP -- >>\"\n\
_coshell_quote='\\\\\\''\n\
set \"$@\" \"$_coshell_stop\"\n\
while :\n\
do case $1 in\n\
$_coshell_stop)\n\
shift\n\
break\n\
;;\n\
*=*) ;;\n\
*) _coshell_state=arg ;;\n\
esac\n\
case $_coshell_state in\n\
exp) _coshell_arg=`echo $1 | sed \"s/\\\\([^=]*\\\\)=\\\\(.*\\\\)/\\\\1=$_coshell_quote\\\\2$_coshell_quote/\"`\n\
set \"\" \"$@\" \"$_coshell_arg\"\n\
shift\n\
;;\n\
arg) set \"\" \"$@\" \"$_coshell_quote$1$_coshell_quote\"\n\
shift\n\
;;\n\
esac\n\
shift\n\
done\n\
case $_coshell_silent in\n\
\"\") set \"set -x;\" \"$@\" ;;\n\
esac\n\
eval \"$@\"\n\
return 0\n\
}'\n\
eval 'silent() {\n\
case $- in\n\
*x*) set -\n\
_coshell_silent=\n\
;;\n\
*) _coshell_silent=1\n\
;;\n\
esac\n\
_coshell_state=exp\n\
_coshell_stop=\"<< -- StoP -- >>\"\n\
_coshell_quote='\\\\\\''\n\
set \"$@\" \"$_coshell_stop\"\n\
while :\n\
do case $1 in\n\
$_coshell_stop)\n\
shift\n\
break\n\
;;\n\
*=*) ;;\n\
*) _coshell_state=arg ;;\n\
esac\n\
case $_coshell_state in\n\
exp) _coshell_arg=`echo $1 | sed \"s/\\\\([^=]*\\\\)=\\\\(.*\\\\)/\\\\1=$_coshell_quote\\\\2$_coshell_quote/\"`\n\
set \"\" \"$@\" \"$_coshell_arg\"\n\
shift\n\
;;\n\
arg) set \"\" \"$@\" \"$_coshell_quote$1$_coshell_quote\"\n\
shift\n\
;;\n\
esac\n\
shift\n\
done\n\
eval \"$@\"\n\
_coshell_state=$?\n\
case $_coshell_silent in\n\
\"\") set -x ;;\n\
esac\n\
return $_coshell_state\n\
}'\n\
else :\n\
fi\n\
";
char cokinit[] = "\
set +o bgnice -o monitor\n\
(wait $$; exit 0) 2>/dev/null || alias wait=:\n\
alias ignore='ignore '\n\
function ignore\n\
{\n\
integer argc=0\n\
typeset argv state=exp\n\
while :\n\
do case $# in\n\
0) break ;;\n\
esac\n\
case $1 in\n\
*=*) ;;\n\
*) state=arg ;;\n\
esac\n\
case $state in\n\
exp) argv[argc]=${1%%=*}=\"'${1#*=}'\" ;;\n\
arg) argv[argc]=\"'\"$1\"'\" ;;\n\
esac\n\
((argc=argc+1))\n\
shift\n\
done\n\
eval \"${argv[@]}\"\n\
return 0\n\
}\n\
alias silent='set +x X$- \"$@\";_coshell_flags_=$1;shift;silent '\n\
function silent\n\
{\n\
case $_coshell_flags_ in\n\
*x*) trap ' _coshell_status_=$?\n\
if ((_coshell_status_==0))\n\
then set -x\n\
else set -x;(set +x;exit $_coshell_status_)\n\
fi' 0\n\
;;\n\
esac\n\
\"$@\"\n\
}\n\
typeset -xf ignore silent\n\
";
char* co_export[] = /* default export var list */
{
CO_ENV_EXPORT, /* first */
CO_ENV_ATTRIBUTES,
CO_ENV_PROC,
"FPATH",
"VPATH",
0 /* last */
};
|