fail when passing non integer

This commit is contained in:
q
2015-07-19 20:53:58 +03:00
parent 3df5a80340
commit 704d3c0df0
2 changed files with 10 additions and 4 deletions

View File

@@ -43,8 +43,11 @@ Simple implementation of head that keeps the header row.
help="File(s) to be headed") help="File(s) to be headed")
opts=parser.parse_args() opts=parser.parse_args()
if not opts.lines: if not opts.lines:
int(opts.file[0]) try:
opts.lines=int(opts.file.pop(0)) int(opts.file[0])
opts.lines=int(opts.file.pop(0))
except:
pass
if not opts.lines: if not opts.lines:
opts.lines=10 opts.lines=10
return opts return opts

View File

@@ -43,8 +43,11 @@ simple implementation of tail, keeping the header row
help="File(s) to be headed") help="File(s) to be headed")
opts=parser.parse_args() opts=parser.parse_args()
if not opts.lines: if not opts.lines:
int(opts.file[0]) try:
opts.lines=opts.file.pop(0) int(opts.file[0])
opts.lines=opts.file.pop(0)
except:
pass
if not opts.lines: if not opts.lines:
opts.lines="10" opts.lines="10"
if opts.lines.startswith("+"): if opts.lines.startswith("+"):