Skip to content

Commit

Permalink
v2.7 from the old code base
Browse files Browse the repository at this point in the history
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
nayas360 committed Jun 25, 2017
1 parent a3a5c08 commit 0d85ffb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
Binary file modified FileSystem.fs
Binary file not shown.
46 changes: 46 additions & 0 deletions bin/cat.py
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)
2 changes: 1 addition & 1 deletion bin/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

v = '''
[version]
v2.6
v2.7
[author]
Sayan Dutta
Expand Down
9 changes: 4 additions & 5 deletions bin/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ def _help():
[options]:
-h Print this help.
-vars Lists all declared
variables.
-del (var) Delete variable
(var) if defined.
Expand All @@ -20,7 +19,7 @@ def _help():
print(usage)

def main(argv):
if len(argv) < 1 or '-h' in argv:
if '-h' in argv:
_help()
return
# The shell doesnt send the
Expand All @@ -30,9 +29,9 @@ def main(argv):
# argv.pop(0) #remove arg

# to show all vars
if '-vars' in argv:
if len(argv) < 1:
for i in prop.vars():
print(i)
print(i, ' = ', prop.get(i))
return
if '-del' in argv:
try:
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Shell prototype
from lib.core import *

P = 'sdcard/com.hipipal.qpyplus/projects3/shell'
P = 'storage/sdcard1/com.hipipal.qpyplus/projects3/shell'
try:
os.chdir(P)
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion shell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Shell prototype
from lib.core import *

P = 'sdcard/com.hipipal.qpyplus/projects3/shell'
P = 'storage/sdcard1/com.hipipal.qpyplus/projects3/shell'
try:
os.chdir(P)
except OSError:
Expand Down

0 comments on commit 0d85ffb

Please sign in to comment.