Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.17 (TBD, 2019)
* Enhancements
* No longer treating empty text scripts as an error condition

## 0.9.16 (August 7, 2019)
* Bug Fixes
* Fixed inconsistent parsing/tab completion behavior based on the value of `allow_redirection`. This flag is
Expand Down
3 changes: 1 addition & 2 deletions cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3790,9 +3790,8 @@ def do_run_script(self, args: argparse.Namespace) -> Optional[bool]:
self.perror("'{}' is not a file".format(expanded_path))
return

# Make sure the file is not empty
# An empty file is not an error, so just return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding something in the CHANGELOG in regards to this change?

if os.path.getsize(expanded_path) == 0:
self.perror("'{}' is empty".format(expanded_path))
return

# Make sure the file is ASCII or UTF-8 encoded text
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def test_run_script_with_empty_file(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
filename = os.path.join(test_dir, 'scripts', 'empty.txt')
out, err = run_cmd(base_app, 'run_script {}'.format(filename))
assert "is empty" in err[0]
assert not out and not err

def test_run_script_with_binary_file(base_app, request):
test_dir = os.path.dirname(request.module.__file__)
Expand Down