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.
Files changed (137) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +674 -0
  3. data/COPYING-DOCS +15 -0
  4. data/README.md +45 -0
  5. data/Rakefile +129 -0
  6. data/TODO +19 -0
  7. data/bin/naksh +2 -0
  8. data/data/default.mo +0 -0
  9. data/data/default.po +16 -0
  10. data/data/default2.mo +0 -0
  11. data/data/default2.po +27 -0
  12. data/data/starter.pot +29 -0
  13. data/docs/bash_flow.dia +0 -0
  14. data/docs/gtk_manual.txt +13 -0
  15. data/docs/master_plan.dia +0 -0
  16. data/docs/master_plan.png +0 -0
  17. data/docs/master_plan.svg +74 -0
  18. data/docs/master_plan.svgz +0 -0
  19. data/docs/userguide/en/about.xml +42 -0
  20. data/docs/userguide/en/gnu-fdl-1.2.xml +543 -0
  21. data/docs/userguide/en/naksh.xml +881 -0
  22. data/docs/userguide/en/naksh_start_window.png +0 -0
  23. data/docs/userguide/en/old_naksh.xml +180 -0
  24. data/docs/userguide/en/userguide-en.omf +37 -0
  25. data/lib/naksh.rb +165 -0
  26. data/lib/naksh/buffer.rb +153 -0
  27. data/lib/naksh/command_handling.rb +117 -0
  28. data/lib/naksh/commands/bash/README +2 -0
  29. data/lib/naksh/commands/bash/echo.nkc.rb +50 -0
  30. data/lib/naksh/commands/bsd.rb +25 -0
  31. data/lib/naksh/commands/dos.rb +25 -0
  32. data/lib/naksh/commands/fuse.rb +25 -0
  33. data/lib/naksh/commands/gnu.rb +30 -0
  34. data/lib/naksh/commands/gnu/README +2 -0
  35. data/lib/naksh/commands/gnu/cat.nkc.rb +50 -0
  36. data/lib/naksh/commands/gnu/cd.nkc.rb +11 -0
  37. data/lib/naksh/commands/gnu/echo.documentation.json +57 -0
  38. data/lib/naksh/commands/gnu/echo.documentation.rb +60 -0
  39. data/lib/naksh/commands/gnu/echo.nkc.rb +52 -0
  40. data/lib/naksh/commands/gnu/ls.nkc.rb +11 -0
  41. data/lib/naksh/commands/gnu/mv.nkc.rb +15 -0
  42. data/lib/naksh/commands/gnu/pwd.nkc.rb +11 -0
  43. data/lib/naksh/commands/naksh/addpath.nkc.rb +15 -0
  44. data/lib/naksh/commands/naksh/broken.nkc.rb +10 -0
  45. data/lib/naksh/commands/naksh/empty.nkc.rb +4 -0
  46. data/lib/naksh/commands/naksh/exit.nkc.rb +10 -0
  47. data/lib/naksh/commands/naksh/help.nkc.rb +21 -0
  48. data/lib/naksh/commands/naksh/man.nkc.rb +8 -0
  49. data/lib/naksh/commands/ruby.rb +31 -0
  50. data/lib/naksh/commands/unix.rb +131 -0
  51. data/lib/naksh/configuration/gconf.rb +51 -0
  52. data/lib/naksh/configuration/hash.rb +38 -0
  53. data/lib/naksh/defaults.rb +40 -0
  54. data/lib/naksh/history.rb +85 -0
  55. data/lib/naksh/interfaces.rb +59 -0
  56. data/lib/naksh/interfaces/fox.rb +49 -0
  57. data/lib/naksh/interfaces/gtk.rb +103 -0
  58. data/lib/naksh/interfaces/gtk/abtwin.rb +53 -0
  59. data/lib/naksh/interfaces/gtk/gnomeapp.rb +31 -0
  60. data/lib/naksh/interfaces/gtk/helpwin.rb +70 -0
  61. data/lib/naksh/interfaces/gtk/io.rb +94 -0
  62. data/lib/naksh/interfaces/gtk/mainwin.rb +56 -0
  63. data/lib/naksh/interfaces/gtk/mainwin/console.rb +121 -0
  64. data/lib/naksh/interfaces/gtk/mainwin/main_menu.rb +143 -0
  65. data/lib/naksh/interfaces/gtk/optwin.rb +78 -0
  66. data/lib/naksh/interfaces/tab.rb +58 -0
  67. data/lib/naksh/interfaces/wxw.rb +75 -0
  68. data/lib/naksh/interfaces/wxw/abtwin.rb +38 -0
  69. data/lib/naksh/interfaces/wxw/helpwin.rb +40 -0
  70. data/lib/naksh/interfaces/wxw/io.rb +61 -0
  71. data/lib/naksh/interfaces/wxw/mainwin.rb +42 -0
  72. data/lib/naksh/interfaces/wxw/mainwin/main_menu.rb +126 -0
  73. data/lib/naksh/interfaces/wxw/mainwin/sessions.rb +49 -0
  74. data/lib/naksh/interfaces/wxw/optwin.rb +37 -0
  75. data/lib/naksh/path_entry.rb +101 -0
  76. data/lib/naksh/regexp.rb +31 -0
  77. data/lib/naksh/session.rb +72 -0
  78. data/lib/naksh/stdlibext.rb +48 -0
  79. data/lib/naksh/syntax.rb +57 -0
  80. data/lib/naksh/syntax/bash.rb +219 -0
  81. data/lib/naksh/syntax/bash/antlr/bottomup.g +24 -0
  82. data/lib/naksh/syntax/bash/antlr/topdown.g +52 -0
  83. data/lib/naksh/syntax/bash/dhaka/evaluator.rb +353 -0
  84. data/lib/naksh/syntax/bash/dhaka/grammar.rb +71 -0
  85. data/lib/naksh/syntax/bash/dhaka/lexer.rb +52 -0
  86. data/lib/naksh/syntax/bash/treetop/bash.treetop +17 -0
  87. data/lib/old/abbr_call.rb +39 -0
  88. data/lib/old/autocomplete.rb +29 -0
  89. data/lib/old/command.rb +106 -0
  90. data/lib/old/command_holder.rb +75 -0
  91. data/lib/old/commands.rb +24 -0
  92. data/lib/old/old_executor.rb +95 -0
  93. data/lib/old/options.rb +31 -0
  94. data/lib/old/rush.rb +113 -0
  95. data/lib/old/sortissimo.rb +205 -0
  96. data/lib/old/systems.rb +25 -0
  97. data/lib/old/systems/ruby.rb +26 -0
  98. data/lib/old/un.rb +240 -0
  99. data/lib/rust/Rakefile +6 -0
  100. data/lib/rust/commands/builtins.rb +46 -0
  101. data/lib/rust/commands/builtins/cd.rb +17 -0
  102. data/lib/rust/commands/builtins/exit.rb +13 -0
  103. data/lib/rust/commands/builtins/help.rb +14 -0
  104. data/lib/rust/commands/builtins/parser.rb +13 -0
  105. data/lib/rust/commands/builtins/pwd.rb +13 -0
  106. data/lib/rust/commands/builtins/type.rb +13 -0
  107. data/lib/rust/commands/commands/ls.rb +13 -0
  108. data/lib/rust/commands/commands/read.rb +13 -0
  109. data/lib/rust/commands/commands/rm.rb +14 -0
  110. data/lib/rust/commands/commands/test.rb +20 -0
  111. data/lib/rust/helpers/array.rb +10 -0
  112. data/lib/rust/helpers/command_center.rb +78 -0
  113. data/lib/rust/helpers/constants.rb +58 -0
  114. data/lib/rust/helpers/io.rb +132 -0
  115. data/lib/rust/helpers/parser.rb +45 -0
  116. data/lib/rust/helpers/rush_control.rb +40 -0
  117. data/lib/rust/helpers/string.rb +50 -0
  118. data/lib/rust/helpers/trollop.rb +475 -0
  119. data/lib/rust/parsers/bash.rb +220 -0
  120. data/lib/rust/parsers/bash/stdlibext.rb +32 -0
  121. data/lib/rust/parsers/ren.rb +57 -0
  122. data/lib/rust/rust.rb +75 -0
  123. data/lib/rust/syntax/command.rb +23 -0
  124. data/lib/rust/syntax/paths.rb +31 -0
  125. data/lib/rust/syntax/pipes.rb +148 -0
  126. data/naksh.gemspec +55 -0
  127. data/test/naksh/arg_parser.rspec.rb +27 -0
  128. data/test/naksh/commands/bash/echo.rspec.rb +32 -0
  129. data/test/naksh/commands/sortlist +127 -0
  130. data/test/naksh/external_command.rspec.rb +46 -0
  131. data/test/naksh/send_error.rspec.rb +60 -0
  132. data/test/naksh/suggest.rspec.rb +38 -0
  133. data/test/naksh/syntax/bash.rspec.rb +69 -0
  134. data/test/naksh/syntax/bash/execute.rspec.rb +51 -0
  135. data/test/naksh/syntax/rspec.rb +63 -0
  136. data/test/run_rspecs.rb +20 -0
  137. metadata +217 -0
@@ -0,0 +1,52 @@
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 'dhaka'
20
+
21
+ class BashDhakaLexerSpecification < Dhaka::LexerSpecification
22
+ KEYWORDS = %w[ until while for if case select ]
23
+
24
+ %w[ | || && ; $ * " ' ].each do |char|
25
+ for_symbol(char) do
26
+ create_token char
27
+ end
28
+ end
29
+
30
+ for_pattern '\s' do
31
+ create_token 'space'
32
+ end
33
+
34
+
35
+
36
+ for_pattern('[\w-]+') do
37
+ if KEYWORDS.include? current_lexeme.value
38
+ create_token current_lexeme.value
39
+ else
40
+ create_token 'word'
41
+ end
42
+ end
43
+
44
+
45
+ =begin
46
+ for_pattern('\d*(\.\d+)?') do
47
+ create_token('numeric_literal')
48
+ end
49
+ =end
50
+
51
+
52
+ end
@@ -0,0 +1,17 @@
1
+ grammar Bash
2
+ rule environmental_variable
3
+ \$\w+
4
+ end
5
+ rule single_quoted_string
6
+ ['][^']*[']
7
+ end
8
+ rule double_quoted_string
9
+ ["][^"]*["]
10
+ end
11
+ rule pipeline
12
+ command_and_args (| command_and_args)*
13
+ end
14
+ rule script
15
+ pipeline (; pipeline ;*)*
16
+ end
17
+ end
@@ -0,0 +1,39 @@
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
+ #THIS FILE CURRENTLY DOESNT GET CALLED
20
+ #IT SHOULD BE MERGED WITH Naksh.autocomplete and Naksh.send_command
21
+
22
+ module Naksh
23
+
24
+ def Naksh.abbr_call(abbr,ary_of_args)
25
+ possibilities=Naksh.autocomplete(abbr)
26
+ if possibilities.length==1
27
+ Naksh.send_command(possibilities[0],ary_of_args)
28
+ else
29
+ Naksh.send_error(_("%{command}: command not found")%{:command=>command})
30
+ if Naksh.options.suggest_on_failure?
31
+ Naksh.buffer.puts(_('Try one of the following commands:'))
32
+ Naksh.pretty_print_array(possibilities)
33
+ end
34
+ Naksh.stop#cancel any later commands
35
+ end
36
+ end
37
+
38
+
39
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/local/bin/ruby
2
+ # (c) 2011-12-05 thefed
3
+ # All pwnage reserved.
4
+
5
+
6
+ class Hell < Exception; end
7
+
8
+ class AutoComplete # part of autocompletion
9
+ def initialize
10
+ @commands = ["build", "buck", "monkey"].sort
11
+ end
12
+ def interpret(arg_frag)
13
+ ret = []
14
+ @commands.each do |com|
15
+ ret << com if com.to_s.match arg_frag # only if it matches
16
+ # TODO break if we're after it
17
+ end
18
+
19
+ if ret.length > 1 # if we found multiple matches
20
+ raise Hell, "Too ambiguous of a command" # raise Hell
21
+ else # else its size = 1
22
+ return ret[0] # return the symbol
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ a = AutoComplete.new
29
+ puts a.interpret("bui")
@@ -0,0 +1,106 @@
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
+
21
+ #what makes a command a command, absolutely nothing,
22
+ #but it better have a 'call' method
23
+ class Command
24
+ end
25
+
26
+
27
+ #this is for making a new command from a file
28
+ class ExternalCommand<Command
29
+ def intialize(path,name=:default)
30
+ if name==:default
31
+ name=File.basename(location)
32
+ if Naksh::Options.drop_extensions?
33
+ md=/\.[^\.]*\z/.match name
34
+ name.replace md.pre_match if md
35
+ end
36
+ end
37
+ @name=name
38
+ @path=path
39
+ self
40
+ end
41
+
42
+ attr_accessor :path,:name
43
+
44
+ #seydar/fedzor work your magic here
45
+ def call(args)
46
+ $stderr.puts "\nNaksh::ExternalCommand\#call\n@path=#{@path.inspect}\nargs=#{args.inspect}"
47
+ raise NotImplementedError
48
+ end
49
+ end
50
+
51
+
52
+ class RubyCommand<Command
53
+
54
+
55
+ #code MUST be a lambda proc
56
+ #I wish there was a way to test that...
57
+
58
+ #arg_count may be the number of arguments this command accepts,
59
+ #or it may be true, to signify that argument parsing should be performed,
60
+ #or it may be false, to signify that argument parsing should be disabled
61
+
62
+ #arg_map is a hash with symbols representing options
63
+ #pointing to either the substituting symbol,
64
+ #an integer for the option's argument count,
65
+ #or an array of these
66
+ def initialize(code,name,arg_count=true,arg_map=nil)
67
+
68
+ raise ArgumentError,"code must be a proc #{code.inspect}" unless code.kind_of? Proc
69
+ name=name.to_s
70
+ raise ArgumentError,"arg_map must be a hash #{arg_map.inspect}" unless !arg_map or arg_map.kind_of? Hash
71
+ arg_map=nil if arg_map==false
72
+
73
+ @arg_map=arg_map
74
+ @arg_count=nil unless arg_count.kind_of? Integer
75
+ @parse_args=arg_count ? true : false
76
+ @code=code
77
+ @name=name
78
+ self
79
+ end
80
+
81
+
82
+ attr_reader :arg_map,:name,:arg_count
83
+ def parse_args?
84
+ @parse_args
85
+ end
86
+
87
+
88
+ def call(args)
89
+ if @parse_args
90
+ args=Naksh.argument_parser(args,@arg_map or Hash.new,@arg_count or 0..1/0)
91
+ end
92
+ begin
93
+ return @code.call(args)
94
+ rescue ThreadError,LocalJumpError
95
+ #this isn't strictly true,
96
+ #these errors could be called elsewise,
97
+ #but this is more helpful to the beginner
98
+ Naksh.send_error(_('Naksh %{method}: Command not defined via lambda')%{:method=>name})
99
+ rescue
100
+ Naksh.send_error(_('Naksh: %{method}: invalid command')%{:method=>name})
101
+ end
102
+ Naksh.remove_command(name) if Naksh::Options.remove_invalid_commands?
103
+ nil
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,75 @@
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 'kirbybase'
20
+
21
+ module Naksh
22
+ #this is an array which holds on to commands
23
+ class CommandHolder<Hash
24
+
25
+ def initialize
26
+ @db=KirbyBase.new(:local,nil,nil,'../data')
27
+ @com_tbl=@db.create_table(:commands,:name,{:DataType=>:String,:Required=>true,:Index=>1},:location,{:DataType=>:String,:Required=>true},:obj_name,:String)
28
+ make_metadata_table if Naksh.options[:keep_metadata_handy?]
29
+ super
30
+ end
31
+
32
+ #add a command
33
+ def <<(other)
34
+
35
+ raise ArgumentError unless other.kind_of? Naksh::Command
36
+
37
+ #KirbyBase is clever; it will call other a Stnkct
38
+ @com_tbl.insert(other)
39
+ end
40
+
41
+
42
+ #find a command
43
+ #useful for metadata queries,
44
+ #use call for actual method calling
45
+ def [](query)
46
+ @rb_com_tbl
47
+ end
48
+
49
+
50
+ #this is how you call commands
51
+ def call(command_name)
52
+ command=self.[command_name]
53
+ command.call
54
+ end
55
+
56
+
57
+ #this is an option which will slow loading,
58
+ #but improve metadata queries,
59
+ #useful for debugging, i guess
60
+ def make_metadata_table
61
+ raise NotImplementError
62
+ @meta_tbl=@db.create_table(:metadata,:name,{:DataType=>:String,:Required=>true,:Index=>1},MORE_STUFF_HERE)
63
+ end
64
+
65
+ end
66
+
67
+
68
+
69
+ def commands
70
+ @commands
71
+ end
72
+
73
+ @commands=CommandHolder.new
74
+
75
+ end
@@ -0,0 +1,24 @@
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
+ #these set hold the actual commands like ls,mv,etc.
21
+ #these are pure emulators, as smart as the originals
22
+ module CommandSets
23
+ end
24
+ end
@@ -0,0 +1,95 @@
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
+ #THIS FILE IS NO LONGER USED,
20
+ #IT IS KEPT SO YOU CAN STEAL CODE AND
21
+ #USE IT IN ANOTHER FILE
22
+
23
+
24
+ class Regexp
25
+ def from_posix(unix_expr)
26
+ Regexp.compile(Regexp.escape(unix_expr).gsub(/\\\?/,'.').gsub(/\\\*/,'.*'))
27
+ end
28
+ end
29
+
30
+ #use libraries to fetch username for tilde expansion
31
+ module Naksh
32
+ USAGE_STRING='naksh.rb [-h | --help][-a | --about][(-e | --execute) script_str]* [(-f | --file) script_path]'
33
+ OPTION_LIST=['-? | -h | --help','-a | --about','-c | --copyright','-u | --usage',['-e | --execute','shell_script_string'],['-f | --file','path_to_shell_script']]
34
+ #includes only compatible shell locations
35
+ UNIX_SHELL_LOCATIONS=%w[/usr/bin/bash /usr/bin/sh]
36
+ def Naksh.option_list
37
+ Naksh::OPTION_LIST.inject do |result,option|
38
+ if option.kind_of? String
39
+ result<<' '<< option
40
+ elsif option.kind_of? Array and option.length==2
41
+ result<<' '<< option.at(0)<<' '<< option.at(1)
42
+ else
43
+ raise RuntimeError,'internal variable (Naksh::OPTION_LIST) is Array with entries not prepared for'
44
+ end
45
+ result
46
+ end
47
+ end
48
+ #fetches scripts and executes them
49
+ #one optional argument
50
+ #(The_scripts_may_be_very_long)? true : false
51
+ def Naksh.run_scripts(care_about_memory=false)
52
+ Naksh.fetch_scripts.at(0).each do |shell_script|
53
+ Naksh.process_script_string(shell_script)
54
+ end
55
+ Naksh.fetch_scripts.at(1).each do |shell_script_path|
56
+ if care_about_memory
57
+ Naksh.process_script_progressively(File.new(shell_script_path))
58
+ else
59
+ Naksh.process_script_string(File.read(shell_script_path))
60
+ end
61
+ end
62
+ end
63
+ def Naksh.shebang(file)
64
+ begin
65
+ file.rewind
66
+ rescue
67
+ end
68
+ begin
69
+ shebang_line=file.readline
70
+ rescue
71
+ raise ArgumentError,'Naksh.shebang requires one argument which responds to readline'
72
+ end
73
+ begin
74
+ file.rewind
75
+ rescue
76
+ end
77
+ return false unless /#!/.match(shebang_line)
78
+ shebang_line.slice(2,shebang_line.length)
79
+ end
80
+ #includes only compatible shells
81
+ def Naksh.file_is_shell_script?(file)
82
+ Naksh::UNIX_SHELL_LOCATIONS.include? Naksh.shebang(file)
83
+ end
84
+ #if user is running a UNIXish operating system, executes via OS
85
+ #if not, will run in Naksh if a shell script
86
+ def Naksh.run_file_by_shebang(file)
87
+ return system(Naksh.shebang(file)<<' '<<file.path) if $OS.unix?
88
+ return Naksh.process_script_progressively(file) if Naksh.file_is_shell_script(file)
89
+ return false
90
+ end
91
+ end
92
+
93
+ __END__
94
+
95
+