Skip to content

Commit 623a988

Browse files
committed
Added warning for arguments containing carriage returns. This happens if a shell script was written in Windows but executed in Linux, as may be the case with bash for Windows.
1 parent e7c1117 commit 623a988

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pythonforandroid/toolchain.py

Lines changed: 7 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,12 @@ def add_parser(subparsers, *args, **kwargs):
575576
# Each subparser corresponds to a method
576577
getattr(self, args.subparser_name.replace('-', '_'))(args)
577578

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

0 commit comments

Comments
 (0)