diff options
-rwxr-xr-x | ponysay.py | 22 | ||||
-rwxr-xr-x | ponysay.sh | 11 |
2 files changed, 13 insertions, 20 deletions
@@ -367,15 +367,19 @@ class ponysay(): alts.append(pair) pairs = alts - pair = pairs[random.randrange(0, len(pairs))] - qfile = None - try: - qfile = open(pair[1], 'r') - args.message = '\n'.join(qfile.readlines()) - finally: - if qfile is not None: - qfile.close() - args.pony = [pair[0]] + if not len(pairs) == 0: + pair = pairs[random.randrange(0, len(pairs))] + qfile = None + try: + qfile = open(pair[1], 'r') + args.message = '\n'.join(qfile.readlines()).strip() + finally: + if qfile is not None: + qfile.close() + args.pony = [pair[0]] + else: + args.pony = args.quote + args.message = 'I got nuthin\' good to say :(' self.print_pony(args) @@ -68,17 +68,6 @@ say() { fi } - - -# If no stdin and no arguments then print usage and exit -if [ -t 0 ] && [ $# == 0 ]; then - usage - exit -fi - - - - # Check for cowsay hash $cmd &>/dev/null; if [ $? -ne 0 ]; then cat >&2 <<EOF |