シェルスクリプト言語xyzshのソースコード。
修订版 | 63acfe8dce71092121ca1ab96da222d177889fa1 (tree) |
---|---|
时间 | 2012-11-02 22:09:01 |
作者 | ab25cq <ab25cq@gmai...> |
Commiter | ab25cq |
v1.1.8 release
@@ -1,4 +1,11 @@ | ||
1 | 1 | |
2 | +2012 30th Octorber version 1.1.8 | |
3 | + | |
4 | + Added -index option to "add" inner command and "del" inner command. | |
5 | + | |
6 | + Added ~/.xyzsh/program mechanizm to entry external program for root | |
7 | + object. See USAGE or USAGE.ja | |
8 | + | |
2 | 9 | 2012 30th Octorber version 1.1.7a |
3 | 10 | |
4 | 11 | Deleted castamized code for CYGWIN. It has not been required. |
@@ -100,6 +100,7 @@ Used files | ||
100 | 100 | ~/.xyzsh/macro --> macro which is runned by typing C-x on command line uses this file |
101 | 101 | ~/.xyzsh/jump --> jump inner command uses this file |
102 | 102 | ~/.xyzsh/menu --> menu inner command uses this file |
103 | + ~/.xyzsh/program --> program list which is entried to root object | |
103 | 104 | |
104 | 105 | Encoding and Line field |
105 | 106 | xyzsh script source file must be written with UTF-8 encode and LF Linefield. But, xyzsh can treat UTF8, EUCJP, and SJIS encodings and can treat LF, CR, LFCR line fields. (EUCJP and SJIS are for Japanese) |
@@ -493,17 +493,15 @@ | ||
493 | 493 | |
494 | 494 | However, fulequently used commands are entried on root object with refference. |
495 | 495 | |
496 | - --- xyzsh.xyzsh --- | |
497 | - | |
498 | - print "cat ls pwd cp mv rm rmdir ln make vi vim perl ruby python sed awk grep egrep find less wc sudo echo which whoami head tail" | split | each ( | |
499 | - | chomp | var -local prog | |
500 | - | |
501 | - try ( sys::run ( root::ref $prog ) | ref $prog) catch () | |
502 | - ) | |
503 | - | |
504 | 496 | So you can use ls without sys:: |
505 | 497 | |
506 | 498 | > ls |
499 | + | |
500 | + If you want to entry new external program for root object, you may add new program name to ~/.xyzsh/program like below and run rehash inner command. | |
501 | + | |
502 | + > print dmesg\n >> ~/.xyzsh/program | |
503 | + > rehash | |
504 | + > dmesg | |
507 | 505 | |
508 | 506 | |
509 | 507 | 2.4 subshell |
@@ -507,24 +507,22 @@ | ||
507 | 507 | |
508 | 508 | 2.3 外部コマンド |
509 | 509 | |
510 | - 外部コマンドは起動時にrehashされてsysオブジェクトの中に外部コマンドオブジェクトとして入れられます。 | |
510 | + 外部コマンドは起動時にrehashされてeysオブジェクトの中に外部コマンドオブジェクトとして入れられます。 | |
511 | 511 | rehash内部コマンドが実行されるたびにsysオブジェクトの中に新しく作られます。 |
512 | 512 | |
513 | 513 | > sys::dmesg # dmesg外部コマンドを実行 |
514 | 514 | |
515 | 515 | ただし、lsなど使用頻度が高いコマンドについてはリファレンスによってルートオブジェクトに登録されています。 |
516 | 516 | |
517 | - --- xyzsh.xyzsh より --- | |
518 | - | |
519 | - print "cat ls pwd cp mv rm rmdir ln make vi vim perl ruby python sed awk grep egrep find less wc sudo echo which whoami head tail" | split | each ( | |
520 | - | chomp | var -local prog | |
521 | - | |
522 | - try ( sys::run ( root::ref $prog ) | ref $prog) catch () | |
523 | - ) | |
524 | - | |
525 | 517 | よってlsなどはsys::を付けなくても実行できます。 |
526 | 518 | |
527 | 519 | > ls # sys::lsでなくても良い |
520 | + | |
521 | + sys::を省略したい外部プログラムを追加するには~/.xyzsh/programにあるプログラム一覧にプログラム名を追加してください。その後rehashをすると追加されます。 | |
522 | + | |
523 | + > print dmesg\n >> ~/.xyzsh/program | |
524 | + > rehash | |
525 | + > dmesg | |
528 | 526 | |
529 | 527 | |
530 | 528 | 2.4 サブシェル |
@@ -844,6 +844,7 @@ add 文字列 | ||
844 | 844 | - |
845 | 845 | 文字列をパイプに追加するフィルター。 |
846 | 846 | |
847 | +-index 数値 数値の位置に文字列を追加する | |
847 | 848 | -number 数値 数値の位置に文字列を追加する |
848 | 849 | -byte バイトコードとして処理する |
849 | 850 | -utf8 UTF8コードとして処理する |
@@ -854,6 +855,7 @@ del インデックス | ||
854 | 855 | - |
855 | 856 | パイプの中のインデックスの位置の文字を一文字削除して残りを出力するフィルター。 |
856 | 857 | |
858 | +-index 文字数 文字数分削除する | |
857 | 859 | -number 文字数 文字数分削除する |
858 | 860 | -byte バイトコードとして処理する |
859 | 861 | -utf8 UTF8コードとして処理する |
@@ -1677,6 +1679,7 @@ add (string) | ||
1677 | 1679 | - |
1678 | 1680 | It is a filter for adding string to pipe data. |
1679 | 1681 | |
1682 | +-index (number) add the string at the number position. | |
1680 | 1683 | -number (number) add the string at the number position. |
1681 | 1684 | -byte assume text encode as byte code. |
1682 | 1685 | -utf8 assume text encode as utf-8 code. |
@@ -1687,6 +1690,7 @@ del (index) | ||
1687 | 1690 | - |
1688 | 1691 | It is a filter for removing a character on pipe data. |
1689 | 1692 | |
1693 | +-index (number) Number characters are removed. | |
1690 | 1694 | -number (number) Number characters are removed. |
1691 | 1695 | -byte assume text encode as byte code. |
1692 | 1696 | -utf8 assume text encode as utf-8 code. |
@@ -1875,6 +1875,9 @@ BOOL cmd_add(sObject* nextin, sObject* nextout, sRunInfo* runinfo) | ||
1875 | 1875 | if(argument = sCommand_option_with_argument_item(command, "-number")) { |
1876 | 1876 | number = atoi(argument); |
1877 | 1877 | } |
1878 | + else if(argument = sCommand_option_with_argument_item(command, "-index")) { | |
1879 | + number = atoi(argument); | |
1880 | + } | |
1878 | 1881 | else { |
1879 | 1882 | number = -1; |
1880 | 1883 | } |
@@ -1956,6 +1959,9 @@ BOOL cmd_del(sObject* nextin, sObject* nextout, sRunInfo* runinfo) | ||
1956 | 1959 | if(argument = sCommand_option_with_argument_item(command, "-number")) { |
1957 | 1960 | number = atoi(argument); |
1958 | 1961 | } |
1962 | + else if(argument = sCommand_option_with_argument_item(command, "-index")) { | |
1963 | + number = atoi(argument); | |
1964 | + } | |
1959 | 1965 | else { |
1960 | 1966 | number = 1; |
1961 | 1967 | } |
@@ -240,10 +240,12 @@ void uobject_root_init(sObject* self) | ||
240 | 240 | |
241 | 241 | nfun = NFUN_NEW_GC(cmd_add, NULL, TRUE); |
242 | 242 | (void)nfun_put_option_with_argument(nfun, STRDUP("-number")); |
243 | + (void)nfun_put_option_with_argument(nfun, STRDUP("-index")); | |
243 | 244 | uobject_put(self, "add", nfun); |
244 | 245 | |
245 | 246 | nfun = NFUN_NEW_GC(cmd_del, NULL, TRUE); |
246 | 247 | (void)nfun_put_option_with_argument(nfun, STRDUP("-number")); |
248 | + (void)nfun_put_option_with_argument(nfun, STRDUP("-index")); | |
247 | 249 | uobject_put(self, "del", nfun); |
248 | 250 | |
249 | 251 | nfun = NFUN_NEW_GC(cmd_index, NULL, TRUE); |
@@ -112,7 +112,7 @@ static void xyzsh_read_rc() | ||
112 | 112 | |
113 | 113 | void xyzsh_init(enum eAppType app_type, BOOL no_runtime_script) |
114 | 114 | { |
115 | - setenv("XYZSH_VERSION", "1.1.7a", 1); | |
115 | + setenv("XYZSH_VERSION", "1.1.8", 1); | |
116 | 116 | setenv("XYZSH_DATAROOTDIR", DATAROOTDIR, 1); |
117 | 117 | |
118 | 118 | stack_init(1);; |
@@ -15,12 +15,26 @@ print ~/.xyzsh | if(| -e) ( | ||
15 | 15 | print 1000 | export XYZSH_HISTSIZE |
16 | 16 | print ~/.xyzsh/history | export XYZSH_HISTFILE |
17 | 17 | |
18 | -print "tee 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 ( | |
18 | +print ~/.xyzsh/program | if(! | -e) ( | |
19 | + print "tee 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 > ~/.xyzsh/program | |
20 | +) | |
21 | + | |
22 | +sys::cat ~/.xyzsh/program | each ( | |
19 | 23 | | chomp | var -local prog |
20 | 24 | |
21 | 25 | try ( sys::run ( root::ref $prog ) | ref $prog) catch () |
22 | 26 | ) |
23 | 27 | |
28 | +def rehash -inherit ( | |
29 | + inherit | |
30 | + | |
31 | + sys::cat ~/.xyzsh/program | each ( | |
32 | + | chomp | var -local prog | |
33 | + | |
34 | + try ( sys::run ( root::ref $prog ) | ref $prog) catch () | |
35 | + ) | |
36 | +) | |
37 | + | |
24 | 38 | prompt ( pwd | chomp | add " > " ) |
25 | 39 | |
26 | 40 | def jump ( |
@@ -40,6 +54,7 @@ def menu ( | ||
40 | 54 | vim ~/.xyzsh/menu |
41 | 55 | vim ~/.xyzsh/macro |
42 | 56 | vim ~/.xyzsh/jump |
57 | +vim ~/.xyzsh/program | |
43 | 58 | ls -al | uc| less |
44 | 59 | pwd | scan . | less |
45 | 60 | ls | each ( if(|chomp | -d) ( | print ) ) |