diff --git a/file_utils/unln.py b/file_utils/unln.py index c11a091..43ca640 100755 --- a/file_utils/unln.py +++ b/file_utils/unln.py @@ -50,21 +50,25 @@ def verbose(*message, **args): if options["verbose"]: print(*message, **args) -def warn(*message, prefix="Warning:", **args): +def warn(*message, prefix="Warning!", **args): """Prints the message on the error output, prepended by 'prefix'. + The standard output is flushed prior to printing the error message, to + enable the messages to be displayed in the right order. + This function is a simple wrapper around print(), and you can use any keyword argument you would use with print(). """ + sys.stdout.flush() print(prefix, *message, file=sys.stderr, **args) def error(error_code, *message, **args): - """Prints the message on the error output and exits. + """Prints the message on the error output and exits with 'error_code'. - This function is a simple wrapper around print(), and you can use any - keyword argument you would use with print(). + This function is a simple wrapper around warn(), and you can use any + keyword argument you would use with warn() or print(). """ - print(*message, file=sys.stderr, **args) + warn(*message, prefix="", **args) sys.exit(error_code) def quote(string): @@ -81,7 +85,7 @@ options = { progname = os.path.basename(sys.argv[0]) # Short usage string -usage_string = "Usage:\n\t{} [file2 ...]\n".format(progname) +usage_string = "Usage:\n\t{} [file2 ...]".format(progname) # Error codes ERR_BAD_USAGE = 1