X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=inline;f=print-filename.py;h=d664d79d360d32b1d92422ae79e9157ff7459db3;hb=65ff4c2e85b037a673c282b02ffa2db10c7eebd3;hp=c0d3c8ee6c31d2d6e9c8e107c8af812a38eea6f2;hpb=9cb89a1ef215ad7aba4132f1ad6441f50cf6cf46;p=xsetbg.git diff --git a/print-filename.py b/print-filename.py index c0d3c8e..d664d79 100755 --- a/print-filename.py +++ b/print-filename.py @@ -20,7 +20,7 @@ import sys, os, shelve def usage(code=0): - sys.stderr.write("Usage: %s [-0|--null] [-o|--old] [-s|--spaces] [-w|--width] [width]\n" % sys.argv[0]) + sys.stderr.write("Usage: %s [-0|--null] [-n|--no-newline] [-o|--old] [-s|--spaces] [-w|--width] [width]\n" % sys.argv[0]) sys.exit(code) @@ -28,12 +28,13 @@ def get_args(): from getopt import getopt, GetoptError try: - options, arguments = getopt(sys.argv[1:], "0osw:", - ["null", "old", "spaces", "width="]) + options, arguments = getopt(sys.argv[1:], "0nosw:", + ["null", "no-newline", "old", "spaces", "width="]) except GetoptError: usage(1) print0 = False + newline = True old = False spaces = '' width = None @@ -43,6 +44,8 @@ def get_args(): usage() elif option in ("-0", "--null"): print0 = True + elif option in ("-n", "--no-newline"): + newline = False elif option in ("-o", "--old"): old = True elif option in ("-s", "--spaces"): @@ -60,9 +63,9 @@ def get_args(): else: width = int(arguments[0]) - return print0, old, spaces, width + return print0, newline, old, spaces, width -print0, old, spaces, width = get_args() +print0, newline, old, spaces, width = get_args() xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg") @@ -97,5 +100,5 @@ sys.stdout.write(filename.encode(default_encoding)) if print0: sys.stdout.write('\0') -else: +elif newline: print