Skip to content

Commit d632f8e

Browse files
authored
Merge pull request #1712 from Aralox/warn-if-crlf-arg
Added warning for arguments containing carriage returns. This happens…
2 parents fca5fc1 + 6d93af1 commit d632f8e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pythonforandroid/toolchain.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ class ToolchainCL(object):
229229
def __init__(self):
230230

231231
argv = sys.argv
232+
self.warn_on_carriage_return_args(argv)
232233
# Buildozer used to pass these arguments in a now-invalid order
233234
# If that happens, apply this fix
234235
# This fix will be removed once a fixed buildozer is released
@@ -575,6 +576,13 @@ def add_parser(subparsers, *args, **kwargs):
575576
# Each subparser corresponds to a method
576577
getattr(self, args.subparser_name.replace('-', '_'))(args)
577578

579+
@staticmethod
580+
def warn_on_carriage_return_args(args):
581+
for check_arg in args:
582+
if '\r' in check_arg:
583+
warning("Argument '{}' contains a carriage return (\\r).".format(str(check_arg.replace('\r', ''))))
584+
warning("Invoking this program via scripts which use CRLF instead of LF line endings will have undefined behaviour.")
585+
578586
def warn_on_deprecated_args(self, args):
579587
"""
580588
Print warning messages for any deprecated arguments that were passed.

0 commit comments

Comments
 (0)