From: Oleg Broytman Date: Tue, 26 Aug 2008 20:11:30 +0000 (+0000) Subject: Added '--no-newline' options. X-Git-Tag: v4.0.0~46 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=65ff4c2e85b037a673c282b02ffa2db10c7eebd3;p=xsetbg.git Added '--no-newline' options. git-svn-id: file:///home/phd/archive/SVN/xsetbg/trunk@22 143022c7-580b-0410-bae3-87f2bf5d3141 --- 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