summaryrefslogtreecommitdiffstats
path: root/fb
diff options
context:
space:
mode:
Diffstat (limited to 'fb')
-rwxr-xr-xfb13
1 files changed, 7 insertions, 6 deletions
diff --git a/fb b/fb
index de8fdea..d4f1b24 100755
--- a/fb
+++ b/fb
@@ -8,7 +8,7 @@
#----------------------------------------------------
'''[cat |] %prog [file1 file2 ...]'''
-__version__ = '0.4.0'
+__version__ = '0.4.1'
__desc__ = '''
Upload file to paste.xinu.at and copy URL to clipboard
or nopaste stdin
@@ -62,7 +62,7 @@ def merge(seq):
merged.append(x)
return merged
-def read_stdin():
+def read_stdin(tmpfile):
if os.isatty(sys.stdin.fileno()):
print '^C to exit, ^D to send'
try:
@@ -71,7 +71,6 @@ def read_stdin():
sys.exit()
if not content:
sys.exit()
- tmpfile = Popen('mktemp', stdout=PIPE).communicate()[0]
tmpfile = tmpfile.replace('\n', '')
f = open(tmpfile, 'w')
f.write(content)
@@ -84,9 +83,13 @@ def main():
description=__desc__+password.__doc__)
p.add_option('-d', '--delete', action='store_true', dest='delete',
help='delete IDs', default=False)
+ p.add_option('-e', '--extension', action='store', dest='extension',
+ help='extension for tempfiles when pipeing (e.g. "diff")', default='')
options, args = p.parse_args()
tmpfiles = []
+ tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0]
+ tmpdir = tmpdir.replace('\n', '')
if args:
for arg in args:
if options.delete:
@@ -94,8 +97,6 @@ def main():
continue
if arg.find('http://') != -1:
- tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0]
- tmpdir = tmpdir.replace('\n', '')
os.chdir(tmpdir)
tmpfiles.append(tmpdir)
Popen(['wget', '-q', arg]).communicate()[0]
@@ -104,7 +105,7 @@ def main():
else:
do_upload(arg)
else:
- tmpfile = read_stdin()
+ tmpfile = read_stdin(tmpdir+"/stdin."+options.extension)
tmpfiles.append(tmpfile)
do_upload(tmpfile)