nyaosorg / nyagos Goto Github PK
View Code? Open in Web Editor NEWNYAGOS - The hybrid Commandline Shell between UNIX & DOS
License: BSD 3-Clause "New" or "Revised" License
NYAGOS - The hybrid Commandline Shell between UNIX & DOS
License: BSD 3-Clause "New" or "Revised" License
例えばヒストリ数が2000の場合に
lua_e "nyagos.gethistory(2002)"
とすると落ちます(2001でないのは、上記コマンドが実行時にヒストリに追加され、リスト長が2001になるため)。
リスト範囲外の参照なのですが、
落ちるのは期待動作ではないと思ったので報告させていただきます。
Japanese: 0文字状態で TAB を押下すると、ドットで始まるファイルだけで補完されてしまう
エラー出力関係で変更があったようなので仕様かもしれませんが
506655f 以降エラーを返さなくなりました。
24247ed 以前
$ invalid_command
exec: "invalid_command": executable file not found in %PATH%
$ lua_e r,e=nyagos.exec('invalid_command');print(e)
exec: "invalid_command": executable file not found in %PATH%
506655f 以降
$ invalid_command
(何も表示されない)
$ lua_e r,e=nyagos.exec('invalid_command');print(e)
(何も表示されない)
bff1264 時点
nyagos.bindkeyで設定した関数実行前に、^Hや"KILL_LINE"で消した入力もtext.textに渡されてしまいます。
nyagos.bindkey("C_X",
function(this)
print("\nthis.text: " .. this.text .. "\n")
return false
end
)
のように^Xにキーバインドを設定している状態で、
$ test string^H^H^H^H^H^H^H^X
this.text: test string
期待値は
this.text: test
だと思います。
文字列がnull終端されてない感じでしょうか?
$ test string
^ ここにカーソルがある状態で^U^Xとすると
this.text: stringstring
と出力されます。
cd x:.
と等価のはずが cd x:\
になってしまっている
The command "ls" marks the folder name as executable in cases like: "github.com"
It should be:
"github.com/" (green)
but shows:
"github.com*" (pink)
In "commands/ls/ls.go" there are two places "dos.IsExecutableSuffix�" is called. Perhaps the dos package could be altered to also check if the path points to a folder, though that would require a FS hit each time.
If you're inclined to fix, I could create a pull request.
-Daniel
32ff056 以降
nyagos.evalでコマンド実行結果を受け取ることができないようです。
例えば以下のようなエイリアス
alias {
hoge=function()
local path = nyagos.eval('pwd')
print("\"".. path .. "\"")
end
}
hoge
の実行結果の期待値は
"(カレントディレクトリ)"
だと思うのですが
""
(カレントディレクトリ)
となります。
This is requested on #41.
zetamatta is going to provide the example.
But others ones are welcome, too.
例えば
nyagos.bindkey("C_C","CLEAR")
のようなCtrl-Cへのマッピングが有効になりません。
panic: runtime error: slice bounds out of range
goroutine 16 [running]:
runtime.panic(0x50a6c0, 0x5cb40f)
c:/go/src/pkg/runtime/panic.c:279 +0xe9
_/C_/Users/Hayama/gosrc/nyagos/history.CmdHistory(0x122f2a00, 0x122fa358, 0x0, 0x0)
C:/Users/Hayama/gosrc/nyagos/history/history.go:232 +0x273
_/C_/Users/Hayama/gosrc/nyagos/commands.Exec(0x122f2a00, 0x122e9700, 0x2d0288, 0x0, 0x554420, 0x0, 0x0)
C:/Users/Hayama/gosrc/nyagos/commands/commands.go:167 +0x412
_/C_/Users/Hayama/gosrc/nyagos/alias.Hook(0x122f2a00, 0x0, 0x2d0288, 0x0, 0x0, 0x0, 0x0)
C:/Users/Hayama/gosrc/nyagos/alias/alias.go:87 +0xca
昨日のマージしていただいたPRなのですが、以下の不備がありました。申し訳ありません
昨日のPR失敗してしまったので、今回は内容を確認していただきたいのですがお願いできませんでしょうか? nocd5@458c1f5
一連のPRで期待する動作は
コンソールのコマンド入力行が更新されたら(コマンド実行やINTR
)history.pointerを初期化し、
カーソルキー上を入力した場合、ヒストリ末尾のコマンドを表示する。
です(nyaosと同等の動作)。
環境変数のPATHに値を追加するために ~/.nyagos
の最終行に
set "PATH+=C:\RailsInstaller\Ruby2.0.0\bin"
と追加すると
C:\Users\ironsand\Dropbox\bin\nyagos\nyagos.lua:71: C:\Users\ironsand\.nyagos:9: invalid escape sequence near '\R'
というエラーになってしまいました。
コンソール上で同じコマンドを読んで echo %PATH%
しても値が変わってないですし、
nyagosではどうやって環境変数を設定すればいいんでしょうか?
nyaosでこんな関数を使っていたのですが
rake{
if exist "Gemfile" then
bundle exec rake %*
else
cmd /c rake %*
endif
}
これはnyagosではどう書き換えられるんでしょうか?
http://qiita.com/zetamatta/items/98cc2ac1fa1f9370667b の説明によると
nyagos.alias
で置き換えができるとのことなので
nyagos.alias("rake",
if exist "Gemfile" then
bundle exec rake %*
else
cmd /c rake %*
endif
)
としてみましたが構文エラーになってしまいました。
以下のように、内臓コマンド which
の結果の途中に \\
が含まれることがあるようです。
$ which powershell
C:\Windows\System32\WindowsPowerShell\v1.0\\powershell.exe
[~]
$ where powershell
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
再現条件は、PATH の最後がスラッシュで終了している場合です。上記の場合、C:\Windows\System32\WindowsPowerShell\v1.0\
が PATH に含まれています。
NYAGOS のバグ、というよりも Go 標準ライブラリ exec.LookPath
の仕様みたいですが、気づいたので報告させていただきました。
On nyagos.exe :
$ gawk "BEGIN{ printf ""%d\n"",0 }"
gawk: コマンドライン:1: BEGIN{ printf "%d\n"",0 }"
gawk: コマンドライン:1: ^ 予想外の改行または文字列の終端があります。
On CMD.EXE :
$ gawk "BEGIN{ printf \""%d\n\"",0 }"
0
On nyagos.exe again :
$ gawk "BEGIN{ printf \""\%d\n\"",0 }"
gawk: BEGIN{ printf \"\%d\n\"",0 }"
gawk: ^ バックスラッシュが行最後の文字になっていません。
メモリ上のヒストリにはappendされているのですが、
~/AppData/Roaming/NYAOS_ORG/nyagos.history
が更新されません。
思ったのですが
https://github.com/zetamatta/nyagos/blob/0c14d46d89a976f5c4743db0a3dab36a39ffa75a/src/nyagos.go#L137
この条件って真になることありますかね?
NYAOS の cmdsource だと読める
$ nyagos -k "cd %USERPROFILE%"
Nihongo Yet Another GOing Shell
lua: C:\Users\Hayama\Share\bin\nyagos.lua:2: attempt to index a nil value (global 'nyagos')
stack traceback:
C:\Users\Hayama\Share\bin\nyagos.lua:2: in main chunk
[C]: in ?
例えば
lua_e "nyagos.eval('notepad.exe')"
notepad終了後にnyagosが落ちます。
また
lua_e "nyagos.eval('存在しないコマンド')"
も同様に落ちます。
nyagos.execは問題ありません。
nyagos 6b97bf5
Go 1.3.1(32bit)
MinGW 4.8.1 (TDM版)
Windows 8.1
$ alias e=echo
$ e hoge
exec: "echo": executable file not found in %PATH%
$ alias e=__echo__
としても同様です。
$ ls -ltr
-rw-Exception 0xc0000006 0x8 0x4aa690 0x4aa690
PC=0x4aa690
time.Unix(0x0, 0x0, 0x8a4bdea8, 0x13ce11ff, 0x1211efe0, 0x12, 0x1211efe0, 0x0)
c:/go/src/time/time.go:969
os.(*fileStat).ModTime(0x12154140, 0x0, 0x0, 0x0, 0x0)
c:/go/src/os/types_windows.go:49 +0x94
_/C_/Users/Hayama/GoSrc/nyagos/commands/ls.lsOneLong(0x549700, 0x1, 0x192e00, 0x
12154140, 0x6f, 0x191d30, 0x120ef030)
C:/Users/Hayama/GoSrc/nyagos/commands/ls/ls.go:102 +0x2a2
_/C_/Users/Hayama/GoSrc/nyagos/commands/ls.lsLong(0x549700, 0x1, 0x120a4250, 0x1
, 0x1, 0x6f, 0x191d30, 0x120ef030)
C:/Users/Hayama/GoSrc/nyagos/commands/ls/ls.go:166 +0x9a
_/C_/Users/Hayama/GoSrc/nyagos/commands/ls.lsFolder(0x549700, 0x1, 0x6e, 0x191d3
0, 0x120ef030, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/commands/ls/ls.go:246 +0x6ee
_/C_/Users/Hayama/GoSrc/nyagos/commands/ls.lsCore(0x121397e4, 0x0, 0x0, 0x6e, 0x
191d30, 0x120ef030, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/commands/ls/ls.go:264 +0x77
_/C_/Users/Hayama/GoSrc/nyagos/commands/ls.Main(0x1211efa8, 0x2, 0x3, 0x191d30,
0x120ef030, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/commands/ls/ls.go:384 +0x72f
_/C_/Users/Hayama/GoSrc/nyagos/commands.cmd_ls(0x120bbe00, 0x1211efa0, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/commands/ls.go:12 +0x101
_/C_/Users/Hayama/GoSrc/nyagos/commands.Exec(0x120bbe00, 0x120a4118, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/commands/commands.go:81 +0x556
_/C_/Users/Hayama/GoSrc/nyagos/alias.hook(0x120bbe00, 0x192f50, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/alias/alias.go:82 +0x62
_/C_/Users/Hayama/GoSrc/nyagos/interpreter.(*Interpreter).Interpret(0x120bbd40,
0x1213cea0, 0xb, 0x12139cf4, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/interpreter/interpreter.go:147 +0x685
_/C_/Users/Hayama/GoSrc/nyagos/alias.(*AliasFunc).Call(0x120fc0f8, 0x120ba900, 0
x120fc0f8, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/alias/alias.go:54 +0x46a
_/C_/Users/Hayama/GoSrc/nyagos/alias.hook(0x120ba900, 0x192f50, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/alias/alias.go:97 +0x1fa
_/C_/Users/Hayama/GoSrc/nyagos/interpreter.(*Interpreter).Interpret(0x120ba600,
0x1213c307, 0x7, 0x7, 0x0, 0x0)
C:/Users/Hayama/GoSrc/nyagos/interpreter/interpreter.go:147 +0x685
main.main()
C:/Users/Hayama/GoSrc/nyagos/main/nyagos.go:191 +0xe0f
goroutine 5 [syscall, 10 minutes]:
os/signal.loop()
c:/go/src/os/signal/signal_unix.go:21 +0x21
created by os/signal.initツキ1
c:/go/src/os/signal/signal_unix.go:27 +0x34
goroutine 6 [chan receive, 10 minutes]:
_/C_/Users/Hayama/GoSrc/nyagos/conio.ctrlCHandler(0x12084ec0)
C:/Users/Hayama/GoSrc/nyagos/conio/getch.go:55 +0x50
created by _/C_/Users/Hayama/GoSrc/nyagos/conio.DisableCtrlC
C:/Users/Hayama/GoSrc/nyagos/conio/getch.go:63 +0xc3
eax 0x8a4bdea8
ebx 0x0
ecx 0x64
edx 0x13ce11ff
edi 0x1211ec5c
esi 0x1211efe0
ebp 0x13ce11e4
esp 0x1213944c
eip 0x4aa690
eflags 0x10206
cs 0x23
fs 0x53
gs 0x2b
要確認
aliasで定義したコマンドを&
付きでバックグラウンド起動すると
パイプでつないでも標準入力から値が受け取れません
$ echo "hoge" | gvim.exe -
-> OK
$ echo "hoge" | gvim.exe - &
-> OK
$ alias g=gvim.exe
$ echo "hoge" | g -
-> OK
$ echo "hoge" | g - &
-> NG
GUIで標準入力から値を受け取るソフトがgvimくらいしかなく、
再現パターンのバリエーションがありませんが、よろしくお願いします。
$ notepad &
(バックグラウンドで起動)
$ alias n=notepad
$ n &
(フォアグラウンドで起動してしまう)
VisualStudioバッチ source 時に不都合
~/AppData/Roaming/NYAOS_ORG/nyagos.history
が存在しない、もしくは空ファイルだと
何かコマンド実行時にクラッシュします。
$ cat test.txt
it
is
a
test
file
.
$ echo "hoge" > test.txt
$ cat test.txt
hoge
s
a
test
file
.
期待値は
hoge
だけだと思いますが、書き込んだ分より元ファイルの方が長いと後半部分が残ります。
UNCパス上でpwd
コマンドを実行してもホスト名と共有名を返しません。
例えば
\\foo\bar\hoge\fuga
でpwd
を実行した場合、実行結果は
hoge\fuga
となります。
commands/pwd.go内のdos.Getwd
に原因があるようでos.Getwd
だと大丈夫です。
カーソル位置が一番左の場合
入力文字列なし→ this.pos: 0
入力文字列あり→ this.pos: 1
文字列入力(例:abc)ありで、カーソル位置が…
一番右(文字列の1つ右) → this.pos: 3
一番右の1つ手前(文字列の最後の文字の上) → this.pos: 3
と、なり、
カーソル位置が同じなのにthis.posの値が違うケースと、
カーソル位置が違うのにthis.posの値が同じになるケースが存在します。
diff --git a/lua_bindkey.go b/lua_bindkey.go
index 566379e..63f1617 100644
--- a/lua_bindkey.go
+++ b/lua_bindkey.go
@@ -96,7 +96,7 @@ func (this *KeyLuaFuncT) Call(buffer *readline.Buffer) readlin
text.WriteRune(c)
}
if pos < 0 {
- pos = text.Len()
+ pos = text.Len() + 1
}
this.L.PushInteger(pos)
this.L.SetField(-2, "pos")
とするとカーソル位置でthis.posの値が一意に決まりますが如何でしょうか?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.