Create cat_dir rule for replacing cat with ls (#823)
* Create `cat_dir` rule for replacing `cat` with `ls` when you try to run `cat` on a directory. * Changed to string methods in response to feedback. Added a test to make sure lines like 'cat cat' don't become 'ls ls'. Added trailing '\n's to test cases.
This commit is contained in:
committed by
Vladimir Iakovlev
parent
142ef6e66c
commit
fe0785bc42
@@ -0,0 +1,10 @@
|
||||
def match(command):
|
||||
return (
|
||||
command.script.startswith('cat') and
|
||||
command.output.startswith('cat: ') and
|
||||
command.output.rstrip().endswith(': Is a directory')
|
||||
)
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
return command.script.replace('cat', 'ls', 1)
|
||||
Reference in New Issue
Block a user