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