-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changelog: > The set module now returns the list of global variables instead of showing help when issued with no arguments. > The type module has been correctly renamed to cat which is the Linux variant of type command in windows which prints file content.
- Loading branch information
Showing
6 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
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,46 @@ | ||
# type command prints file contents | ||
from lib.utils import * | ||
|
||
|
||
def _help(): | ||
usage = ''' | ||
Usage: cat (file) | ||
Print content of (file) | ||
Use '%' in front of global | ||
vars to use value as file | ||
name. | ||
''' | ||
print(usage) | ||
|
||
|
||
def main(argv): | ||
if len(argv) < 1 or '-h' in argv: | ||
_help() | ||
return | ||
# The shell doesnt send the | ||
# command name in the arg list | ||
# so the next line is not needed | ||
# anymore | ||
# argv.pop(0) | ||
|
||
# The shell does the work of replacing | ||
# vars already. Code segment below | ||
# is not required anymore. | ||
# argv=replace_vars(argv) | ||
argv = make_s(argv) | ||
|
||
path = get_path() + argv | ||
if os.path.isfile(path): | ||
with open(path) as f: | ||
data = f.readlines() | ||
print('_________________<START>_________________\n') | ||
print(make_s2(data)) | ||
print('__________________<END>__________________\n') | ||
return | ||
elif os.path.isdir(path): | ||
err(3, add=argv + ' is a directory') | ||
else: | ||
err(2, path) |
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
|
||
v = ''' | ||
[version] | ||
v2.6 | ||
v2.7 | ||
[author] | ||
Sayan Dutta | ||
|
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