• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

シェルスクリプト言語xyzshのソースコード。


Commit MetaInfo

修訂b2dda1a4320e086b85b3633654b5f34203b686a1 (tree)
時間2012-10-18 22:00:35
作者ab25q <ab25cq@gmai...>
Commiterab25q

Log Message

v1.0.9b release

Change Summary

差異

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,18 @@
22 2012 18th Octorber version 1.0.9b
33
44 fixed break in while loop bug
5+ fixed output pipe bug
6+
7+ > (print aaa\n; print bbb\n > b; print ccc\n ) > a
8+
9+ can be worked just as one intended
10+
11+ > cat a
12+ aaa
13+ ccc
14+
15+ > cat b
16+ bbb
517
618 2012 17th Octorber version 1.0.9a
719
--- a/src/block.c
+++ b/src/block.c
@@ -1269,7 +1269,7 @@ BOOL sCommand_expand_env(sCommand* command, sObject* fun, sObject* nextin, sObje
12691269 return TRUE;
12701270 }
12711271
1272-BOOL sCommand_expand_env_redirect(sCommand* command, sObject* nextin, sObject* nextout, sRunInfo* runinfo)
1272+BOOL sCommand_expand_env_redirect(sCommand* command, sObject* nextin, sRunInfo* runinfo)
12731273 {
12741274 if(command->mRedirectsNum > 0) {
12751275 command->mRedirectsFileNamesRuntime = MALLOC(sizeof(char*)*command->mRedirectsNum);
--- a/src/cmd_obj.c
+++ b/src/cmd_obj.c
@@ -66,19 +66,15 @@ static BOOL entry_fun(sObject* nextin, sObject* nextout, sRunInfo* runinfo, sObj
6666 if(sCommand_option_item(command, "-inherit")) {
6767 sObject* parent = hash_item(object, command->mArgsRuntime[1]);
6868 if(parent) {
69-/*
70- if(SFUN(parent).mParentCount > XYZSH_INHERIT_MAX) {
71- err_msg("can't inherit a parent function because of a parent function number limit", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
72- return FALSE;
69+ if(type == T_FUN && (TYPE(parent) == T_FUN || TYPE(parent) == T_NFUN)
70+ || type == T_CLASS && TYPE(parent) == T_CLASS)
71+ {
72+ SFUN(block).mParent = parent;
7373 }
74-*/
75- if(type == T_CLASS && (TYPE(parent) == T_FUN || TYPE(parent) == T_NFUN) || type == T_FUN && TYPE(parent) == T_CLASS) {
74+ else {
7675 err_msg("can't inherit a parent function beacuse of the different type", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
7776 return FALSE;
7877 }
79-
80- SFUN(block).mParent = parent;
81-// SFUN(block).mParentCount = SFUN(parent).mParentCount + 1;
8278 }
8379 else {
8480 err_msg("can't inherit. There is not a parent", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
@@ -467,6 +463,14 @@ BOOL cmd_var(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
467463 int i;
468464 int max = vector_count(SFD(nextin).fdbuf.mLines);
469465 for(i=1; i<command->mArgsNumRuntime; i++) {
466+ sObject* current = runinfo->mCurrentObject;
467+ sObject* tmp = access_object3(command->mArgsRuntime[i], &current);
468+
469+ if(tmp && !sCommand_option_item(command, "-force")) {
470+ err_msg("can't overwrite other the same name variable. Use -force option", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
471+ return FALSE;
472+ }
473+
470474 if(i-1 < max) {
471475 sObject* new_var = STRING_NEW_GC(vector_item(SFD(nextin).fdbuf.mLines, i-1), TRUE);
472476 string_chomp(new_var);
@@ -951,6 +955,15 @@ BOOL cmd_ary(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
951955 int i;
952956 int max = vector_count(SFD(nextin).fdbuf.mLines);
953957 sObject* new_ary = VECTOR_NEW_GC(16, TRUE);
958+
959+ sObject* current = runinfo->mCurrentObject;
960+ sObject* tmp = access_object3(command->mArgsRuntime[1], &current);
961+
962+ if(tmp && !sCommand_option_item(command, "-force")) {
963+ err_msg("can't overwrite other the same name variable. Use -force option", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
964+ return FALSE;
965+ }
966+
954967 hash_put(object, command->mArgsRuntime[1], new_ary);
955968 for(i=0; i<max; i++) {
956969 sObject* new_var = STRING_NEW_GC(vector_item(SFD(nextin).fdbuf.mLines, i), FALSE);
@@ -1150,6 +1163,15 @@ BOOL cmd_hash(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
11501163 int i;
11511164 int max = vector_count(SFD(nextin).fdbuf.mLines);
11521165 sObject* new_hash = HASH_NEW_GC(16, TRUE);
1166+
1167+ sObject* current = runinfo->mCurrentObject;
1168+ sObject* tmp = access_object3(command->mArgsRuntime[1], &current);
1169+
1170+ if(tmp && !sCommand_option_item(command, "-force")) {
1171+ err_msg("can't overwrite other the same name variable. Use -force option", runinfo->mSName, runinfo->mSLine, command->mArgs[0]);
1172+ return FALSE;
1173+ }
1174+
11531175 hash_put(object, command->mArgsRuntime[1], new_hash);
11541176 sObject* key = STRING_NEW_STACK("");
11551177 for(i=0; i<max; i++) {
--- a/src/run.c
+++ b/src/run.c
@@ -124,33 +124,6 @@ BOOL bufsiz_write(int fd, char* buf, int buf_size)
124124 return TRUE;
125125 }
126126
127-// TRUE: Success
128-// FALSE: signal interrupt. set RCODE_SIGNAL_INTERRUPT on rcode and err message
129-/*
130-BOOL globalin_read(sObject* self, sObject* out, unsigned int line_number, enum eLineField lf)
131-{
132- assert(TYPE(self) == T_FD && SFD(self).mKind == kFDKindBuf);
133- assert(TYPE(out) == T_FD && SFD(out).mKind == kFDKindBuf);
134-
135- fd_split(self, lf);
136-
137- if(line_number == 0) line_number = vector_count(SFD(self).fdbuf.mLines);
138-
139- int i;
140- for(i=gGlobalPipeInReadNumber; i < vector_count(SFD(self).fdbuf.mLines) && i < line_number+gGlobalPipeInReadNumber; i++) {
141- char* line = vector_item(SFD(self).fdbuf.mLines, i);
142-
143- if(!fd_write(out, line, strlen(line))) {
144- return FALSE;
145- }
146- }
147-
148- gGlobalPipeInReadNumber += line_number;
149-
150- return TRUE;
151-}
152-*/
153-
154127 void fd_split(sObject* self, enum eLineField lf)
155128 {
156129 assert(TYPE(self) == T_FD && SFD(self).mKind == kFDKindBuf);
@@ -1124,7 +1097,7 @@ static BOOL redirect_ready(sObject** nextout, sObject** nextin, int* opened_fd,
11241097 break;
11251098
11261099 case REDIRECT_APPEND:
1127- if(SFD(*nextout).mKind == kFDKindBuf) {
1100+ if(*nextout == NULL) {
11281101 fd = open(command->mRedirectsFileNamesRuntime[i], O_WRONLY|O_APPEND|O_CREAT, 0644);
11291102 if(fd < 0) {
11301103 char buf[BUFSIZ];
@@ -1139,7 +1112,7 @@ static BOOL redirect_ready(sObject** nextout, sObject** nextin, int* opened_fd,
11391112 break;
11401113
11411114 case REDIRECT_OUT:
1142- if(SFD(*nextout).mKind == kFDKindBuf) {
1115+ if(*nextout == NULL) {
11431116 fd = open(command->mRedirectsFileNamesRuntime[i], O_WRONLY|O_CREAT|O_TRUNC, 0644);
11441117 if(fd < 0) {
11451118 char buf[BUFSIZ];
@@ -1239,30 +1212,33 @@ static BOOL statment_tree(sStatment* statment, sObject* pipein, sObject* pipeout
12391212 const BOOL last_program = runinfo->mLastProgram = i == statment->mCommandsNum-1;
12401213 runinfo->mFilter = i != 0 || (statment->mFlags & (STATMENT_CONTEXTPIPE|STATMENT_GLOBALPIPEIN));
12411214
1242- sObject* nextout;
1243- if(last_program) {
1244- if(statment->mFlags & STATMENT_GLOBALPIPEOUT) {
1245- fd_clear(gGlobalPipe);
1246- nextout = gGlobalPipe;
1247- }
1248- else {
1249- nextout = pipeout;
1250- }
1251- }
1252- else {
1253- nextout = FD_NEW_STACK(kFDKindBuf, 0);
1254- }
1255-
12561215 /// expand env ///
1257- if(!sCommand_expand_env_redirect(command, nextin, nextout, runinfo))
1216+ if(!sCommand_expand_env_redirect(command, nextin, runinfo))
12581217 {
12591218 return FALSE;
12601219 }
12611220
1221+ sObject* nextout = NULL;
1222+
12621223 int opened_fd = -1;
12631224 if(!redirect_ready(&nextout, &nextin, &opened_fd, pipeout, last_program, statment, command, runinfo)) {
12641225 return TRUE;
12651226 }
1227+
1228+ if(nextout == NULL) {
1229+ if(last_program) {
1230+ if(statment->mFlags & STATMENT_GLOBALPIPEOUT) {
1231+ fd_clear(gGlobalPipe);
1232+ nextout = gGlobalPipe;
1233+ }
1234+ else {
1235+ nextout = pipeout;
1236+ }
1237+ }
1238+ else {
1239+ nextout = FD_NEW_STACK(kFDKindBuf, 0);
1240+ }
1241+ }
12661242
12671243 if(command->mArgsNum > 0) {
12681244 if(command->mArgsEnv[0]) {
--- a/src/xyzsh/xyzsh.h
+++ b/src/xyzsh/xyzsh.h
@@ -741,7 +741,7 @@ char* sCommand_option_with_argument_item(sCommand* self, char* key);
741741 BOOL sCommand_put_option(sCommand* self, MANAGED char* key);
742742 BOOL sCommand_put_option_with_argument(sCommand* self, MANAGED char* key, MANAGED char* argument);
743743 BOOL sCommand_expand_env(sCommand* command, sObject* object, sObject* nextin, sObject* nextout, sRunInfo* runinfo);
744-BOOL sCommand_expand_env_redirect(sCommand* command, sObject* nextin, sObject* nextout, sRunInfo* runinfo);
744+BOOL sCommand_expand_env_redirect(sCommand* command, sObject* nextin, sRunInfo* runinfo);
745745 void sCommand_sweep_runtime_info(sCommand* command);
746746
747747 extern sObject* gMemChecker;
--- a/xyzsh.xyzsh
+++ b/xyzsh.xyzsh
@@ -13,7 +13,7 @@ print ~/.xyzsh | if(| -e) (
1313 print 1000 | export XYZSH_HISTSIZE
1414 print ~/.xyzsh/history | export XYZSH_HISTFILE
1515
16-print "diff seq env sleep ps kill killall pkill autoconf automake od nm gcc uname chgrp chmod chown sed awk make git ssh scp tar sudo gzip bash cat ls pwd cp mv rm rmdir ln vi vim grep egrep find less wc echo which whoami head tail uniq mkdir touch man" | split | each (
16+print "find unzip diff seq env sleep ps kill killall pkill autoconf automake od nm gcc uname chgrp chmod chown sed awk make git ssh scp tar sudo gzip bash cat ls pwd cp mv rm rmdir ln vi vim grep egrep find less wc echo which whoami head tail uniq mkdir touch man" | split | each (
1717 | chomp | var -local prog
1818
1919 try ( sys::run ( root::ref $prog ) | ref $prog) catch ()