Commits

seydar committed 05b2d43 Draft

holy shit i think i fixed the issue with nullout. turns out it wasn't opened for writing DUH

Comments (0)

Files changed (7)

     -> sharing of variables between chitin processes
 *   remove trailing whitespace from lines somehow. maybe as a final transformation when you hit enter?
 *   `other_ls = method(:ls)` would be cool. note that ls is mapped to a binary and is not actually a method
+*   pass environment to child processes
+*   tab complete ruby/shell things
 
 QUIRKS:
 *   menu doesn't erase itself sometimes
     -> cat and tabcomplete a file that is empty. output is correct but confusing
+*   does not play nice with GDB if it is called within the bash profile file
 
 FAILURES:
 *   `pdflatex("full.tex") > NULLOUT` fails to produce the PDF,
 *   ^C on running ruby programs kills the whole interpreter... womp.
 *   slashes in filenames
 *   `include Math; sin(5)` fails
+*   `ll` and then `_` results in failure
 
 Questions:
 *   Why do you have to do @line = '' in Coolline in order to not affect the
   require(File.dirname(File.expand_path(__FILE__)) + '/' + file)
 end
 
+require 'date'
+require 'fileutils'
+require 'pp'
+
 need 'chitin/version'
 need 'chitin/support'
 need 'chitin/file'
 need 'chitin/sandbox'
 need 'chitin/session'
 
-require 'date'
-require 'fileutils'
-require 'pp'
-

lib/chitin/commands/builtins.rb

       end
     end
 
-    # L for Lambda. Creates a proc as a RubyMethod
-    def L(&block)
-      StringMethod.new :bottle, &block
-    end
-
     # ruby's backtick doesn't chomp off the newline, which makes it more
     # or less useless for piping into other commands
     def `(args); super(args).chomp; end
       def all; D('.'); end
 
       def to_num; L {|i| i.to_i }; end
+      def p(*args)
+        args.map do |arg|
+          if Runnable === arg
+            puts arg[:inspect]
+          else
+            puts arg.inspect
+          end
+        end
+
+        # i know puts returns nil, but this is to emphasize
+        # the fact that we want it to return nil
+        nil 
+      end
     end
     include Aliases
     
       end
       
       def method_missing(name, *args, &block)
+        if meth = lookup(name, *args, &block)
+          return meth
+        end
+      
+        # If we made it this far, there is no executable to be had. Super it up.
+        super
+      end
+  
+      def raw_exec(path, *args)
+        Executable.new path, *args
+      end
+      alias_method :here, :raw_exec
+      alias_method :h, :raw_exec
+
+      def lookup(name, *args, &block)
         if PRIORITY_METHODS.include? name
           return StringMethod.new(name, *args, &block)
         end
         if "".public_methods(false).include? name
           return StringMethod.new(name, *args, &block)
         end
-      
-        # If we made it this far, there is no executable to be had. Super it up.
-        super
+
+        nil
       end
-  
-      def raw_exec(path, *args)
-        Executable.new path, *args
-      end
-      alias_method :here, :raw_exec
-      alias_method :h, :raw_exec
     end
     include ExecutableBinaries
   

lib/chitin/core_ext/object.rb

 
   # it does NOT return self, but rather the value of block.
   # if no block is given, it returns nil
+  # it's the equivalent of `with(object=nil) {|obj| blah }`
   def bottle # since it's not tap
     if block_given?
       yield self

lib/chitin/core_ext/string.rb

   def /(other)
     Chitin::Executable.new File.join(self, other.to_s)
   end
+
+  def >>(other)
+    case other
+    when Chitin::FileObject
+      other.to_a.each do |fo|
+        next if fo.directory?
+
+        File.open(fo.to_s, 'a') {|f| f.puts self }
+      end
+    when String
+      File.open(other, 'a') {|f| f.puts self }
+    else
+      raise "Unknown piping type: #{other.class}"
+    end
+  
+    other
+  end
+
+  def >(other)
+    case other
+    when Chitin::FileObject
+      other.to_a.each do |fo|
+        next if fo.directory?
+
+        File.open(fo.to_s, 'w') {|f| f.puts self }
+      end
+    when String
+      File.open(other, 'w') {|f| f.puts self }
+    else
+      raise "Unknown piping type: #{other.class}"
+    end
+  
+    other
+  end
+
+  def |(other)
+    L { self } | other
+  end
 end
 

lib/chitin/file.rb

     def symlink?
       false
     end
+
+    def directory?
+      false
+    end
   end
 
   class FileObject < FSObject
     def inspect
       "#<Chitin::Directory #{path.inspect}>"
     end
+
+    def directory?
+      true
+    end
   end
 end
 
   alias_method :f, :F
   alias_method :s, :S
 
-  NULLIN = NULLOUT = NULLERR = File.open File::NULL
+  # L for Lambda. Creates a proc as a RubyMethod
+  def L(&block)
+    StringMethod.new :bottle, &block
+  end
+
+  NULLIN = NULLOUT = NULLERR = File.open(File::NULL, 'w+')
 end
 

lib/chitin/session.rb

           # searching so we need it removed for now.
           unquoted_line = ['"', '\''].include?(line[0, 1]) ? line[1..-1] : line
   
+          #options  = Dir[unquoted_line + '*']
+          #options += 
+
           Dir[unquoted_line + '*'].map do |w|
             slash_it = File.directory?(w) and line[-1] != '/' and w[-1] != '/'