naksh 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/COPYING +674 -0
- data/COPYING-DOCS +15 -0
- data/README.md +45 -0
- data/Rakefile +129 -0
- data/TODO +19 -0
- data/bin/naksh +2 -0
- data/data/default.mo +0 -0
- data/data/default.po +16 -0
- data/data/default2.mo +0 -0
- data/data/default2.po +27 -0
- data/data/starter.pot +29 -0
- data/docs/bash_flow.dia +0 -0
- data/docs/gtk_manual.txt +13 -0
- data/docs/master_plan.dia +0 -0
- data/docs/master_plan.png +0 -0
- data/docs/master_plan.svg +74 -0
- data/docs/master_plan.svgz +0 -0
- data/docs/userguide/en/about.xml +42 -0
- data/docs/userguide/en/gnu-fdl-1.2.xml +543 -0
- data/docs/userguide/en/naksh.xml +881 -0
- data/docs/userguide/en/naksh_start_window.png +0 -0
- data/docs/userguide/en/old_naksh.xml +180 -0
- data/docs/userguide/en/userguide-en.omf +37 -0
- data/lib/naksh.rb +165 -0
- data/lib/naksh/buffer.rb +153 -0
- data/lib/naksh/command_handling.rb +117 -0
- data/lib/naksh/commands/bash/README +2 -0
- data/lib/naksh/commands/bash/echo.nkc.rb +50 -0
- data/lib/naksh/commands/bsd.rb +25 -0
- data/lib/naksh/commands/dos.rb +25 -0
- data/lib/naksh/commands/fuse.rb +25 -0
- data/lib/naksh/commands/gnu.rb +30 -0
- data/lib/naksh/commands/gnu/README +2 -0
- data/lib/naksh/commands/gnu/cat.nkc.rb +50 -0
- data/lib/naksh/commands/gnu/cd.nkc.rb +11 -0
- data/lib/naksh/commands/gnu/echo.documentation.json +57 -0
- data/lib/naksh/commands/gnu/echo.documentation.rb +60 -0
- data/lib/naksh/commands/gnu/echo.nkc.rb +52 -0
- data/lib/naksh/commands/gnu/ls.nkc.rb +11 -0
- data/lib/naksh/commands/gnu/mv.nkc.rb +15 -0
- data/lib/naksh/commands/gnu/pwd.nkc.rb +11 -0
- data/lib/naksh/commands/naksh/addpath.nkc.rb +15 -0
- data/lib/naksh/commands/naksh/broken.nkc.rb +10 -0
- data/lib/naksh/commands/naksh/empty.nkc.rb +4 -0
- data/lib/naksh/commands/naksh/exit.nkc.rb +10 -0
- data/lib/naksh/commands/naksh/help.nkc.rb +21 -0
- data/lib/naksh/commands/naksh/man.nkc.rb +8 -0
- data/lib/naksh/commands/ruby.rb +31 -0
- data/lib/naksh/commands/unix.rb +131 -0
- data/lib/naksh/configuration/gconf.rb +51 -0
- data/lib/naksh/configuration/hash.rb +38 -0
- data/lib/naksh/defaults.rb +40 -0
- data/lib/naksh/history.rb +85 -0
- data/lib/naksh/interfaces.rb +59 -0
- data/lib/naksh/interfaces/fox.rb +49 -0
- data/lib/naksh/interfaces/gtk.rb +103 -0
- data/lib/naksh/interfaces/gtk/abtwin.rb +53 -0
- data/lib/naksh/interfaces/gtk/gnomeapp.rb +31 -0
- data/lib/naksh/interfaces/gtk/helpwin.rb +70 -0
- data/lib/naksh/interfaces/gtk/io.rb +94 -0
- data/lib/naksh/interfaces/gtk/mainwin.rb +56 -0
- data/lib/naksh/interfaces/gtk/mainwin/console.rb +121 -0
- data/lib/naksh/interfaces/gtk/mainwin/main_menu.rb +143 -0
- data/lib/naksh/interfaces/gtk/optwin.rb +78 -0
- data/lib/naksh/interfaces/tab.rb +58 -0
- data/lib/naksh/interfaces/wxw.rb +75 -0
- data/lib/naksh/interfaces/wxw/abtwin.rb +38 -0
- data/lib/naksh/interfaces/wxw/helpwin.rb +40 -0
- data/lib/naksh/interfaces/wxw/io.rb +61 -0
- data/lib/naksh/interfaces/wxw/mainwin.rb +42 -0
- data/lib/naksh/interfaces/wxw/mainwin/main_menu.rb +126 -0
- data/lib/naksh/interfaces/wxw/mainwin/sessions.rb +49 -0
- data/lib/naksh/interfaces/wxw/optwin.rb +37 -0
- data/lib/naksh/path_entry.rb +101 -0
- data/lib/naksh/regexp.rb +31 -0
- data/lib/naksh/session.rb +72 -0
- data/lib/naksh/stdlibext.rb +48 -0
- data/lib/naksh/syntax.rb +57 -0
- data/lib/naksh/syntax/bash.rb +219 -0
- data/lib/naksh/syntax/bash/antlr/bottomup.g +24 -0
- data/lib/naksh/syntax/bash/antlr/topdown.g +52 -0
- data/lib/naksh/syntax/bash/dhaka/evaluator.rb +353 -0
- data/lib/naksh/syntax/bash/dhaka/grammar.rb +71 -0
- data/lib/naksh/syntax/bash/dhaka/lexer.rb +52 -0
- data/lib/naksh/syntax/bash/treetop/bash.treetop +17 -0
- data/lib/old/abbr_call.rb +39 -0
- data/lib/old/autocomplete.rb +29 -0
- data/lib/old/command.rb +106 -0
- data/lib/old/command_holder.rb +75 -0
- data/lib/old/commands.rb +24 -0
- data/lib/old/old_executor.rb +95 -0
- data/lib/old/options.rb +31 -0
- data/lib/old/rush.rb +113 -0
- data/lib/old/sortissimo.rb +205 -0
- data/lib/old/systems.rb +25 -0
- data/lib/old/systems/ruby.rb +26 -0
- data/lib/old/un.rb +240 -0
- data/lib/rust/Rakefile +6 -0
- data/lib/rust/commands/builtins.rb +46 -0
- data/lib/rust/commands/builtins/cd.rb +17 -0
- data/lib/rust/commands/builtins/exit.rb +13 -0
- data/lib/rust/commands/builtins/help.rb +14 -0
- data/lib/rust/commands/builtins/parser.rb +13 -0
- data/lib/rust/commands/builtins/pwd.rb +13 -0
- data/lib/rust/commands/builtins/type.rb +13 -0
- data/lib/rust/commands/commands/ls.rb +13 -0
- data/lib/rust/commands/commands/read.rb +13 -0
- data/lib/rust/commands/commands/rm.rb +14 -0
- data/lib/rust/commands/commands/test.rb +20 -0
- data/lib/rust/helpers/array.rb +10 -0
- data/lib/rust/helpers/command_center.rb +78 -0
- data/lib/rust/helpers/constants.rb +58 -0
- data/lib/rust/helpers/io.rb +132 -0
- data/lib/rust/helpers/parser.rb +45 -0
- data/lib/rust/helpers/rush_control.rb +40 -0
- data/lib/rust/helpers/string.rb +50 -0
- data/lib/rust/helpers/trollop.rb +475 -0
- data/lib/rust/parsers/bash.rb +220 -0
- data/lib/rust/parsers/bash/stdlibext.rb +32 -0
- data/lib/rust/parsers/ren.rb +57 -0
- data/lib/rust/rust.rb +75 -0
- data/lib/rust/syntax/command.rb +23 -0
- data/lib/rust/syntax/paths.rb +31 -0
- data/lib/rust/syntax/pipes.rb +148 -0
- data/naksh.gemspec +55 -0
- data/test/naksh/arg_parser.rspec.rb +27 -0
- data/test/naksh/commands/bash/echo.rspec.rb +32 -0
- data/test/naksh/commands/sortlist +127 -0
- data/test/naksh/external_command.rspec.rb +46 -0
- data/test/naksh/send_error.rspec.rb +60 -0
- data/test/naksh/suggest.rspec.rb +38 -0
- data/test/naksh/syntax/bash.rspec.rb +69 -0
- data/test/naksh/syntax/bash/execute.rspec.rb +51 -0
- data/test/naksh/syntax/rspec.rb +63 -0
- data/test/run_rspecs.rb +20 -0
- metadata +217 -0
data/naksh.gemspec
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'rubygems'
|
|
20
|
+
require 'rake'
|
|
21
|
+
|
|
22
|
+
$spec=Gem::Specification.new do |s|
|
|
23
|
+
s.name = 'naksh'
|
|
24
|
+
s.version = '0.2.0'
|
|
25
|
+
s.add_dependency 'gettext'
|
|
26
|
+
s.author = 'Mahmut Bulut'
|
|
27
|
+
s.autorequire = 'lib/naksh.rb'
|
|
28
|
+
s.default_executable = 'bin/naksh'
|
|
29
|
+
=begin
|
|
30
|
+
s.desciption = <<EOS
|
|
31
|
+
Naksh is an interactive shell
|
|
32
|
+
with Bash syntax emulation,
|
|
33
|
+
interfaces in GTK and Wx,
|
|
34
|
+
but so far only a small set of commands.
|
|
35
|
+
However, the project is under active development.
|
|
36
|
+
EOS
|
|
37
|
+
=end
|
|
38
|
+
s.bindir = 'bin'
|
|
39
|
+
s.email = 'scienceblock@gmail.com'
|
|
40
|
+
s.executables = FileList['binc/**']
|
|
41
|
+
s.extra_rdoc_files = %w[ README.md ]
|
|
42
|
+
s.files = FileList["**/*"].exclude('.svn').exclude('pkg').to_a
|
|
43
|
+
s.has_rdoc = true
|
|
44
|
+
s.homepage = 'http://github.com/regularlambda/naksh'
|
|
45
|
+
#s.platform = Gem::Platform::RUBY
|
|
46
|
+
s.rdoc_options << '--title' << 'Naksh' <<
|
|
47
|
+
'--main' << 'README.md' <<
|
|
48
|
+
'--line-numbers'
|
|
49
|
+
s.require_path = 'lib'
|
|
50
|
+
#s.required_ruby_version ANYONE FEEL LIKE TRYING AN OLD VERSION OF RUBY?
|
|
51
|
+
#s.requirements = ' ENTER A STUPID BUT FRIENDLY REMARK HERE '
|
|
52
|
+
s.rubyforge_project = 'naksh'
|
|
53
|
+
s.summary = 'Nodal Associative Knowledge Shell'
|
|
54
|
+
s.test_file = 'test/run_rspecs.rb'
|
|
55
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'spec'
|
|
20
|
+
|
|
21
|
+
describe "the argument parser for commands" do
|
|
22
|
+
it "must remove options before mapping them"
|
|
23
|
+
#options are removed if unknown_opts==:args or not unknown_opts and opt_map
|
|
24
|
+
#in Ruby:
|
|
25
|
+
#['-a','-b','something']#=>['-b','something'],options=[:b] if opt_map={:a=>:b} and unknown_opts=:args
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
# GPLv3
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
|
|
6
|
+
require 'spec'
|
|
7
|
+
require 'naksh.rb'
|
|
8
|
+
|
|
9
|
+
describe 'bash/echo.nkc.rb' do
|
|
10
|
+
before :all do
|
|
11
|
+
location=File.join(__FILE__,'../../../../lib/naksh/commands/bash/echo.nkc.rb')
|
|
12
|
+
Naksh.buffer.out=Object.new
|
|
13
|
+
class<<Naksh.buffer.out
|
|
14
|
+
def print(*a)
|
|
15
|
+
@test_str<<a.join('')
|
|
16
|
+
end
|
|
17
|
+
def pp(*a)
|
|
18
|
+
$stderr.puts 'pp not implemented'
|
|
19
|
+
end
|
|
20
|
+
attr_reader :test_str
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should skip the new line if the -n flag is present' do
|
|
25
|
+
args={['hey']=>'hey',['hey you']=>'hey you',['hey','you']=>'hey you'}
|
|
26
|
+
args.each_pair do |key,value|
|
|
27
|
+
Naksh.run_nkc(location,key)
|
|
28
|
+
Naksh.buffer.out.test_str.should ==value
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
´´
|
|
2
|
+
`
|
|
3
|
+
^
|
|
4
|
+
¨¨
|
|
5
|
+
~~
|
|
6
|
+
÷
|
|
7
|
+
<
|
|
8
|
+
=
|
|
9
|
+
>
|
|
10
|
+
¬¬
|
|
11
|
+
¦¦
|
|
12
|
+
°°
|
|
13
|
+
µ
|
|
14
|
+
|
|
15
|
+
__
|
|
16
|
+
¯¯
|
|
17
|
+
|
|
18
|
+
--
|
|
19
|
+
,,
|
|
20
|
+
;
|
|
21
|
+
:
|
|
22
|
+
!
|
|
23
|
+
¡
|
|
24
|
+
?
|
|
25
|
+
¿
|
|
26
|
+
·
|
|
27
|
+
¸
|
|
28
|
+
'
|
|
29
|
+
"
|
|
30
|
+
««
|
|
31
|
+
»»
|
|
32
|
+
((
|
|
33
|
+
))
|
|
34
|
+
[[
|
|
35
|
+
]]
|
|
36
|
+
{{
|
|
37
|
+
}}
|
|
38
|
+
§§
|
|
39
|
+
¶
|
|
40
|
+
©©
|
|
41
|
+
®®
|
|
42
|
+
@@
|
|
43
|
+
¤¤
|
|
44
|
+
¢¢
|
|
45
|
+
$$
|
|
46
|
+
££
|
|
47
|
+
¥¥
|
|
48
|
+
**
|
|
49
|
+
&&
|
|
50
|
+
#
|
|
51
|
+
%%
|
|
52
|
+
++
|
|
53
|
+
±±
|
|
54
|
+
♵
|
|
55
|
+
♳
|
|
56
|
+
♿
|
|
57
|
+
♻
|
|
58
|
+
⚁
|
|
59
|
+
Ⓐ
|
|
60
|
+
⚀
|
|
61
|
+
♼
|
|
62
|
+
⚓
|
|
63
|
+
⒈
|
|
64
|
+
⒜
|
|
65
|
+
⚃
|
|
66
|
+
⚗
|
|
67
|
+
⑴
|
|
68
|
+
♺
|
|
69
|
+
♹
|
|
70
|
+
⚄
|
|
71
|
+
♾
|
|
72
|
+
⚅
|
|
73
|
+
⚖
|
|
74
|
+
♴
|
|
75
|
+
⚕
|
|
76
|
+
⁋
|
|
77
|
+
♽
|
|
78
|
+
⁉
|
|
79
|
+
⚂
|
|
80
|
+
①
|
|
81
|
+
⚒
|
|
82
|
+
⁇
|
|
83
|
+
⚘
|
|
84
|
+
⚔
|
|
85
|
+
⁈
|
|
86
|
+
¼
|
|
87
|
+
½
|
|
88
|
+
¾
|
|
89
|
+
00
|
|
90
|
+
1
|
|
91
|
+
¹
|
|
92
|
+
11
|
|
93
|
+
111
|
|
94
|
+
2
|
|
95
|
+
22
|
|
96
|
+
²²
|
|
97
|
+
222
|
|
98
|
+
33
|
|
99
|
+
³³
|
|
100
|
+
9
|
|
101
|
+
a
|
|
102
|
+
Á
|
|
103
|
+
À
|
|
104
|
+
Â
|
|
105
|
+
Å
|
|
106
|
+
Ä
|
|
107
|
+
Ã
|
|
108
|
+
aa
|
|
109
|
+
AA
|
|
110
|
+
ªª
|
|
111
|
+
aaa
|
|
112
|
+
æ
|
|
113
|
+
Æ
|
|
114
|
+
b
|
|
115
|
+
B
|
|
116
|
+
n
|
|
117
|
+
N
|
|
118
|
+
o
|
|
119
|
+
O
|
|
120
|
+
º
|
|
121
|
+
r
|
|
122
|
+
s
|
|
123
|
+
S
|
|
124
|
+
ß
|
|
125
|
+
t
|
|
126
|
+
z
|
|
127
|
+
Z
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'spec'
|
|
20
|
+
|
|
21
|
+
describe Naksh::ExternalCommand do
|
|
22
|
+
#should it accept Pathname?
|
|
23
|
+
it 'should provide access to its path and name' do
|
|
24
|
+
path_str='/usr/local/bin/some_program'
|
|
25
|
+
name_str='random_name'
|
|
26
|
+
ec=Naksh::ExternalCommand.new(path_str,name_str)
|
|
27
|
+
ec.path.should ==path_str
|
|
28
|
+
ec.name.should ==name_str
|
|
29
|
+
end
|
|
30
|
+
it 'should be able to pick a name if one isn\'t provided' do
|
|
31
|
+
Naksh::Options.drop_extensions?=false
|
|
32
|
+
ec1=Naksh::ExternalCommand.new('/usr/bin/sample_program1.sh')
|
|
33
|
+
ec1.name.should =='sample_program1.sh'
|
|
34
|
+
Naksh::Options.drop_extensions?=true
|
|
35
|
+
ec2=Naksh::ExternalCommand.new('/usr/bin/sample_program2.sh')
|
|
36
|
+
ec2.name.should =='sample_program2'
|
|
37
|
+
ec3=Naksh::ExternalCommand.new('/usr/bin/sample.program3.bash.sh')
|
|
38
|
+
ec3.name.should =='sample.program3.bash'
|
|
39
|
+
end
|
|
40
|
+
it 'should not respond to changes in Options.drop_extensions? after it has been created' do
|
|
41
|
+
Naksh::Options.drop_extensions?=false
|
|
42
|
+
ec1=Naksh::ExternalCommand.new('/usr/bin/sample_program1.sh')
|
|
43
|
+
Naksh::Options.drop_extensions?=true
|
|
44
|
+
ec1.name.should =='sample_program1.sh'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'spec'
|
|
20
|
+
require 'naksh.rb'
|
|
21
|
+
require 'stringio'
|
|
22
|
+
|
|
23
|
+
describe Naksh.method(:send_error) do
|
|
24
|
+
before :all do
|
|
25
|
+
sio=Object.new
|
|
26
|
+
def sio.to_s
|
|
27
|
+
@to_s
|
|
28
|
+
end
|
|
29
|
+
def sio.pp(arg)
|
|
30
|
+
@to_s=arg
|
|
31
|
+
end
|
|
32
|
+
def sio.print(str)
|
|
33
|
+
@to_s=str
|
|
34
|
+
end
|
|
35
|
+
Naksh.buffer.out=sio
|
|
36
|
+
str="a reasonable error"
|
|
37
|
+
end
|
|
38
|
+
it "should output to Naksh.buffer.out" do
|
|
39
|
+
Naksh.send_error(str)
|
|
40
|
+
sio.to_s.chop.should ==str
|
|
41
|
+
end
|
|
42
|
+
it "should raise an error unless its argument can't be converted to a string" do
|
|
43
|
+
Naksh.buffer.out=
|
|
44
|
+
o=Object.new
|
|
45
|
+
class<<o
|
|
46
|
+
undef_method :to_s,:to_str,:inspect
|
|
47
|
+
end
|
|
48
|
+
begin
|
|
49
|
+
Naksh.send_error(o)
|
|
50
|
+
worked=true
|
|
51
|
+
rescue
|
|
52
|
+
worked=false
|
|
53
|
+
end
|
|
54
|
+
worked.should be_false
|
|
55
|
+
end
|
|
56
|
+
it "should stop further processing" do
|
|
57
|
+
Naksh.send_error("Naksh: a reasonable error")
|
|
58
|
+
Naksh.stopped?.should be_true
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'spec'
|
|
20
|
+
describe Naksh do
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
describe Naksh.method(:suggestions) do
|
|
24
|
+
it 'should use a spell checker' do
|
|
25
|
+
#Naksh.suggestions('xml-cpy-editor')#=>'xml-copy-editor'
|
|
26
|
+
end
|
|
27
|
+
it 'should use autocomplete if the entry it short or not found' do
|
|
28
|
+
#autocomplete is the next best thing
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe Naksh.method(:complete) do
|
|
34
|
+
it 'should be fast'
|
|
35
|
+
it 'should include all available commands'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
#
|
|
6
|
+
# Naksh is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# Naksh is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with Naksh. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
require 'spec'
|
|
20
|
+
|
|
21
|
+
#this is really testing Bash.find_unescaped_nonstring
|
|
22
|
+
describe Naksh::Syntax::Bash.method(:remove_comments) do
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
it 'should return unmodified an uncommented script' do
|
|
26
|
+
["abc -gf --fake|great 'wonderful';cool\nawesome"].each do |s|
|
|
27
|
+
Naksh::Syntax::Bash.remove_comments(s).should eql?(s)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
it 'should ignore escaped comment symbols' do
|
|
33
|
+
[
|
|
34
|
+
"echo The \\\# here does not begin a comment.",
|
|
35
|
+
"abc -gf --fake \\\#|great 'wonderful';cool\\\\\\\#\nawesome"].each do |s|
|
|
36
|
+
Naksh::Syntax::Bash.remove_comments(s).should eql?(s)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
it 'should ignore comment symbols in strings' do
|
|
42
|
+
[
|
|
43
|
+
"echo \"The # here does not begin a comment.\"",
|
|
44
|
+
"echo 'The # here does not begin a comment.'",
|
|
45
|
+
"abc -gf --fake '#'|great 'wonderful';cool \"\\\\\#\n\"\nawesome"].each do |s|
|
|
46
|
+
Naksh::Syntax::Bash.remove_comments(s).should eql?(s)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
it 'should remove unescaped comments which aren\'t in strings' do
|
|
52
|
+
{
|
|
53
|
+
"echo The \# here begins a comment."=>"echo The "
|
|
54
|
+
"abc -gf --fake '#'|great 'wonderful'#really wonderful\n;cool \"\\\\\#\n\"#\nawesome"=>"abc -gf --fake '#'|great 'wonderful'\n;cool \"\\\\\#\n\"\nawesome"}.each_pair do |i,o|
|
|
55
|
+
Naksh::Syntax::Bash.remove_comments(i).should eql?(o)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
it 'should be able to handle any random combination of escaping, strings, and comments' do
|
|
61
|
+
{"\#a\nbc\\nde\\'f\#g\n\\\\\"hi;\#j;\\\"\"kl;\n\#mn\#\nop\\\#qrs#"=>/\A\n?bc\\nde\\'f\n\\\\\"hi;\#j;\\\"\"kl;\n\n?op\\\#qrs\z/}.each_pair do |i,re|
|
|
62
|
+
Naksh::Syntax::Bash.remove_comments(i).should match?(re)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# echo ${PATH#*:} # Parameter substitution, not a comment.
|
|
67
|
+
# echo $(( 2#101011 )) # Base conversion, not a comment.
|
|
68
|
+
|
|
69
|
+
end
|