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
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
|
|
20
|
+
class NotExpectedFiletypeError<TypeError
|
|
21
|
+
end
|
|
22
|
+
class CompatibilityError<ArgumentError
|
|
23
|
+
end
|
|
24
|
+
class NoCommandError<StandardError
|
|
25
|
+
include Naksh::NonCriticalError
|
|
26
|
+
end
|
|
27
|
+
class NkcLoadError<LoadError
|
|
28
|
+
include Naksh::NonCriticalError
|
|
29
|
+
end
|
|
30
|
+
#looking through this file, you're going to ask,
|
|
31
|
+
#sooner or later, what is nkc?
|
|
32
|
+
#NKC could be an acronym for Naksh Command,
|
|
33
|
+
#but that's not really important
|
|
34
|
+
#I have chosen to identify these ready-made commands
|
|
35
|
+
#by naming the files **.nkc.rb
|
|
36
|
+
#and generally calling them nkcs
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
module Naksh
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# this is just what you expect it to be,
|
|
43
|
+
# an Array of path entries, see PathEntry
|
|
44
|
+
def Naksh.path
|
|
45
|
+
@path
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#this is in case you want to save and swap paths, very useful
|
|
50
|
+
def Naksh.path=(new_path)
|
|
51
|
+
@path=new_path
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
#running a command made for us is easy as pie
|
|
57
|
+
def Naksh.run_nkc(location,args)
|
|
58
|
+
begin
|
|
59
|
+
prc=eval(File.new(location.to_s).read)
|
|
60
|
+
rescue Exception=>err
|
|
61
|
+
raise NkcLoadError,_('error in command: %s: `%s\'')%[location.sub(File.join(Naksh.config['/dir'],'lib'),''),err.to_s.sub(/\(eval\):\d+:in\s`run_nkc':\scompile error\s*/,"\n")]
|
|
62
|
+
end
|
|
63
|
+
raise NotExpectedFiletypeError,_("#{location} isn't a compatible NKC") unless prc.kind_of? Proc or not prc.lambda?
|
|
64
|
+
raise CompatibilityError,_(location.to_s+' must be written for a future version of Naksh; it requires too many arguments') unless prc.arity.abs==1
|
|
65
|
+
prc.call(args)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
#this is for normal commands you can run from any shell
|
|
70
|
+
def Naksh.run_external_file(location,args)
|
|
71
|
+
$stderr.puts 'external command execution not yet implemented'
|
|
72
|
+
0
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def Naksh.send_command(command,args)
|
|
77
|
+
raise ArgumentError unless command.kind_of? String and args.kind_of? Array
|
|
78
|
+
@path.each do |path_entry|
|
|
79
|
+
case path_entry.type
|
|
80
|
+
when :nkc
|
|
81
|
+
return run_nkc(path_entry.location,args) if path_entry.name==command
|
|
82
|
+
when :external
|
|
83
|
+
return run_external_file(path_entry.location,args) if path_entry.name==command
|
|
84
|
+
when :nkc_dir
|
|
85
|
+
path_entry.location.children.each do |child|
|
|
86
|
+
begin
|
|
87
|
+
return run_nkc(child,args) if (/\A(.+)\.nkc\.rb\z/.match(File.basename(child))[1])==command
|
|
88
|
+
rescue Naksh::NonCriticalError=>error
|
|
89
|
+
Naksh.buffer.clear
|
|
90
|
+
Naksh.interface.err.print((_('Naksh: %s')%[error.to_s])<<"\n")
|
|
91
|
+
return false
|
|
92
|
+
rescue NoMethodError
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
when :external_dir
|
|
96
|
+
path_entry.location.children.each do |child|
|
|
97
|
+
return run_external_file(path_entry.location,args) if File.basename(child)==command and File.file? child
|
|
98
|
+
end
|
|
99
|
+
when :mixed_dir
|
|
100
|
+
path_entry.location.children.each do |child|
|
|
101
|
+
md=/\A(.+)\.nkc\.rb\z/.match(File.basename(child))
|
|
102
|
+
if md
|
|
103
|
+
return run_nkc(child,args) if md[1]==command
|
|
104
|
+
else
|
|
105
|
+
return run_external_file(child,args) if File.basename(child)==command and File.file? child
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
else
|
|
109
|
+
raise RuntimeError
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
raise NoCommandError,_("%s: command not found")%[command]
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
@path = Array.new
|
|
116
|
+
|
|
117
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
# GPLv3
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
|
|
6
|
+
#http://www.gnu.org/software/bash/manual/bashref.html#index-echo-133
|
|
7
|
+
|
|
8
|
+
lambda do |input|
|
|
9
|
+
allow_escapes=false
|
|
10
|
+
suppress_line=false
|
|
11
|
+
input.collect! do |arg|
|
|
12
|
+
md=/\A\-([eEn]+)\z/.match(arg)
|
|
13
|
+
if md
|
|
14
|
+
md[1].each_byte do |c|
|
|
15
|
+
c=c.chr
|
|
16
|
+
case c
|
|
17
|
+
when 'e'
|
|
18
|
+
allow_escapes=true
|
|
19
|
+
when 'E'
|
|
20
|
+
allow_escapes=false
|
|
21
|
+
when 'n'
|
|
22
|
+
suppress_line=true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
md ? nil : arg
|
|
27
|
+
end
|
|
28
|
+
result=input.compact.join(' ')
|
|
29
|
+
if allow_escapes
|
|
30
|
+
result.gsub! '\\a',"\a"
|
|
31
|
+
result.gsub! '\\b',"\b"
|
|
32
|
+
raise NotImplementedError if /\\c/.match(result)
|
|
33
|
+
result.gsub! '\\e',"\e"
|
|
34
|
+
result.gsub! '\\f',"\f"
|
|
35
|
+
result.gsub! '\\n',"\n"
|
|
36
|
+
result.gsub! '\\r',"\r"
|
|
37
|
+
result.gsub! '\\t',"\t"
|
|
38
|
+
result.gsub! '\\f',"\f"
|
|
39
|
+
result.gsub! '\\\\','\\'
|
|
40
|
+
result.gsub!(/\\0([0-7]{0,3})/) do |match|
|
|
41
|
+
match[2..-1].to_i(8).chr
|
|
42
|
+
end
|
|
43
|
+
result.gsub!(/\\x(\h{1,2})/) do |match|
|
|
44
|
+
match[2..-1].to_i(16).chr
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
result<<"\n" unless suppress_line
|
|
48
|
+
Naksh.buffer.print result
|
|
49
|
+
0
|
|
50
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
module Naksh
|
|
20
|
+
module CommandSets
|
|
21
|
+
#all of the commands as implemented in Bsd
|
|
22
|
+
module Bsd
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
module Naksh
|
|
20
|
+
module CommandSets
|
|
21
|
+
#accept DOS commands, why not?, low priority
|
|
22
|
+
module Dos
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
module Naksh
|
|
20
|
+
module CommandSets
|
|
21
|
+
#http://rubyforge.org/projects/fusefs/
|
|
22
|
+
module FuseFS
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
module Naksh
|
|
20
|
+
module CommandSets
|
|
21
|
+
#all of the commands written by GNU
|
|
22
|
+
module Gnu
|
|
23
|
+
def Unix.sort(args=[])
|
|
24
|
+
a=Naksh.argument_parser(args,1..1/0,:b=>:ignore_leading_blanks,:d=>:dictionary_order,:f=>:ignore_case,:g=>:general_numeric_sort,:i=>:ignore_nonprinting,:M=>:month_sort,:n=>:numeric_sort,:r=>:reverse,:C=>:check,:k=>:key,:m=>:merge,:o=>:output,:s=>:stable,:S=>:buffer_size,:t=>:field_separator,:T=>:temporary_directory,:u=>:unique,:a=>:zero_terminated)
|
|
25
|
+
p a
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/local/bin/ruby
|
|
2
|
+
# 2011 Mahmut Bulut
|
|
3
|
+
# GPLv3
|
|
4
|
+
# This file is part of Naksh.
|
|
5
|
+
|
|
6
|
+
#http://www.gnu.org/software/coreutils/manual/coreutils.html#cat-invocation
|
|
7
|
+
|
|
8
|
+
lambda do |input|
|
|
9
|
+
show_line_endings = false
|
|
10
|
+
show_tabs = false
|
|
11
|
+
show_nonprinting = false
|
|
12
|
+
number_all_lines = false
|
|
13
|
+
number_nonblank_lines = false
|
|
14
|
+
squeeze_blank = false
|
|
15
|
+
input.collect! do |arg|
|
|
16
|
+
raise NotImplementedError
|
|
17
|
+
result=arg
|
|
18
|
+
if arg.start_with? '-'
|
|
19
|
+
case arg
|
|
20
|
+
when '--show-all'
|
|
21
|
+
show_line_endings = true
|
|
22
|
+
show_tabs = true
|
|
23
|
+
show_nonprinting = true
|
|
24
|
+
when '--number'
|
|
25
|
+
number_all_lines = true
|
|
26
|
+
when '--number-nonblank'
|
|
27
|
+
number_nonblank_lines = true
|
|
28
|
+
when '--show-ends'
|
|
29
|
+
show_line_endings = true
|
|
30
|
+
when '--show-nonprinting'
|
|
31
|
+
show_nonprinting = true
|
|
32
|
+
when '--squeeze-blank'
|
|
33
|
+
squeeze_blank = true
|
|
34
|
+
when '--help'
|
|
35
|
+
raise NotImplementedError
|
|
36
|
+
else
|
|
37
|
+
result=nil
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
result
|
|
41
|
+
end
|
|
42
|
+
input.compact!
|
|
43
|
+
line_number=0
|
|
44
|
+
while r=Naksh.buffer.gets
|
|
45
|
+
line_number+=1 if not number_nonblank_lines or r.empty?
|
|
46
|
+
r=line_number.pad(6,' ')<<r if number_all_lines
|
|
47
|
+
Naksh.buffer.puts r
|
|
48
|
+
end
|
|
49
|
+
0
|
|
50
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status" : "\\c is questionable",
|
|
3
|
+
"name" : "echo",
|
|
4
|
+
"short_description" : "Print a line of text",
|
|
5
|
+
"synopsis" : "echo [option]... [string]...",
|
|
6
|
+
"author" : "Mahmut Bulut",
|
|
7
|
+
"report_bugs" : "mailto:naksh-developers@rubyforge.org",
|
|
8
|
+
"copyright" : "2011 Mahmut Bulut GPLv3",
|
|
9
|
+
"last_modification" : "1198892637",
|
|
10
|
+
"designed_from" : "GNU coreutils 6.9 echo documentation",
|
|
11
|
+
"long_description" : "echo: Print a line of text
|
|
12
|
+
|
|
13
|
+
echo writes each given string to standard output, with a space between each and a newline after the last one. Synopsis:
|
|
14
|
+
|
|
15
|
+
echo [option]... [string]...
|
|
16
|
+
|
|
17
|
+
The program accepts the following options. Also see Common options. Options must precede operands, and the normally-special argument ‘--’ has no special meaning and is treated like any other string.
|
|
18
|
+
|
|
19
|
+
‘-n’
|
|
20
|
+
Do not output the trailing newline.
|
|
21
|
+
‘-e’
|
|
22
|
+
Enable interpretation of the following backslash-escaped characters in each string:
|
|
23
|
+
|
|
24
|
+
‘\a’
|
|
25
|
+
alert (bell)
|
|
26
|
+
‘\b’
|
|
27
|
+
backspace
|
|
28
|
+
‘\c’
|
|
29
|
+
suppress trailing newline
|
|
30
|
+
‘\f’
|
|
31
|
+
form feed
|
|
32
|
+
‘\n’
|
|
33
|
+
new line
|
|
34
|
+
‘\r’
|
|
35
|
+
carriage return
|
|
36
|
+
‘\t’
|
|
37
|
+
horizontal tab
|
|
38
|
+
‘\v’
|
|
39
|
+
vertical tab
|
|
40
|
+
‘\\’
|
|
41
|
+
backslash
|
|
42
|
+
‘\0nnn’
|
|
43
|
+
the eight-bit value that is the octal number nnn (zero to three octal digits)
|
|
44
|
+
‘\nnn’
|
|
45
|
+
the eight-bit value that is the octal number nnn (one to three octal digits)
|
|
46
|
+
‘\xhh’
|
|
47
|
+
the eight-bit value that is the hexadecimal number hh (one or two hexadecimal digits)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
‘-E’
|
|
51
|
+
Disable interpretation of backslash escapes in each string. This is the default. If -e and -E are both specified, the last one given takes effect.
|
|
52
|
+
|
|
53
|
+
If the POSIXLY_CORRECT environment variable is set, then when echo's first argument is not -n it outputs option-like arguments instead of treating them as options. For example, echo -ne hello outputs ‘-ne hello’ instead of plain ‘hello’.
|
|
54
|
+
|
|
55
|
+
POSIX does not require support for any options, and says that the behavior of echo is implementation-defined if any string contains a backslash or if the first argument is -n. Portable programs can use the printf command if they need to omit trailing newlines or output control characters or backslashes. See printf invocation.
|
|
56
|
+
|
|
57
|
+
An exit status of zero indicates success, and a nonzero value indicates failure."}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'scooter/email.rb'
|
|
2
|
+
require 'xri/url.rb'
|
|
3
|
+
#this is superior in content quality to the json version
|
|
4
|
+
{
|
|
5
|
+
:status => "\\c is questionable",
|
|
6
|
+
:name => "echo",
|
|
7
|
+
:short_description => "Print a line of text",
|
|
8
|
+
:synopsis => "echo [option]... [string]...",
|
|
9
|
+
:author => "Mahmut Bulut",
|
|
10
|
+
:report_bugs => "naksh-developers@rubyforge.org".to_email_address,
|
|
11
|
+
:copyright => "2011 Mahmut Bulut GPLv3",
|
|
12
|
+
:last_modification => Time.at(1198892637),
|
|
13
|
+
"designed_from" => "GNU coreutils 6.9 echo documentation",
|
|
14
|
+
:long_description => %q{echo: Print a line of text
|
|
15
|
+
|
|
16
|
+
echo writes each given string to standard output, with a space between each and a newline after the last one. Synopsis:
|
|
17
|
+
|
|
18
|
+
echo [option]... [string]...
|
|
19
|
+
|
|
20
|
+
The program accepts the following options. Also see Common options. Options must precede operands, and the normally-special argument ‘--’ has no special meaning and is treated like any other string.
|
|
21
|
+
|
|
22
|
+
‘-n’
|
|
23
|
+
Do not output the trailing newline.
|
|
24
|
+
‘-e’
|
|
25
|
+
Enable interpretation of the following backslash-escaped characters in each string:
|
|
26
|
+
|
|
27
|
+
‘\a’
|
|
28
|
+
alert (bell)
|
|
29
|
+
‘\b’
|
|
30
|
+
backspace
|
|
31
|
+
‘\c’
|
|
32
|
+
suppress trailing newline
|
|
33
|
+
‘\f’
|
|
34
|
+
form feed
|
|
35
|
+
‘\n’
|
|
36
|
+
new line
|
|
37
|
+
‘\r’
|
|
38
|
+
carriage return
|
|
39
|
+
‘\t’
|
|
40
|
+
horizontal tab
|
|
41
|
+
‘\v’
|
|
42
|
+
vertical tab
|
|
43
|
+
‘\\’
|
|
44
|
+
backslash
|
|
45
|
+
‘\0nnn’
|
|
46
|
+
the eight-bit value that is the octal number nnn (zero to three octal digits)
|
|
47
|
+
‘\nnn’
|
|
48
|
+
the eight-bit value that is the octal number nnn (one to three octal digits)
|
|
49
|
+
‘\xhh’
|
|
50
|
+
the eight-bit value that is the hexadecimal number hh (one or two hexadecimal digits)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
‘-E’
|
|
54
|
+
Disable interpretation of backslash escapes in each string. This is the default. If -e and -E are both specified, the last one given takes effect.
|
|
55
|
+
|
|
56
|
+
If the POSIXLY_CORRECT environment variable is set, then when echo's first argument is not -n it outputs option-like arguments instead of treating them as options. For example, echo -ne hello outputs ‘-ne hello’ instead of plain ‘hello’.
|
|
57
|
+
|
|
58
|
+
POSIX does not require support for any options, and says that the behavior of echo is implementation-defined if any string contains a backslash or if the first argument is -n. Portable programs can use the printf command if they need to omit trailing newlines or output control characters or backslashes. See printf invocation.
|
|
59
|
+
|
|
60
|
+
An exit status of zero indicates success, and a nonzero value indicates failure.}}
|