Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
head command and start the piping integration
- Loading branch information
Showing
8 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* head.js | ||
* head -- display first lines of a file/tweet | ||
* Copyright 2010 Monther. All rights reserved. | ||
* | ||
* require 'inode.h.js' | ||
* require 'shell.h.js' | ||
* require 'commands.js' | ||
* require 'iostream.js' | ||
*/ | ||
shell.command.head = function(){ | ||
this.name = "head"; | ||
this.aliases = new Array("head"); | ||
this.help = "display first lines of a file"; | ||
|
||
this.errors = function(){ | ||
var error_arr = new Array(); | ||
error_arr["NOINPUT"] = "requires an input"; | ||
error_arr["EBADF"] = "option require an argument"; | ||
return []; | ||
} | ||
|
||
this.call = function(args){ | ||
var count = 3; | ||
var data = args[0]; | ||
var parser = null; | ||
if( typeof(data['data']) != undefined){ | ||
parser = data['parser']; | ||
data = data['data']; | ||
} | ||
data = data.slice(0,count); | ||
shell.std.cout(data , parser); | ||
} | ||
} | ||
shell.commands.require("head") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters