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