summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Reinert <mail@jreinert.com>2013-07-28 13:36:36 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-07-28 13:42:43 +0200
commit0acf745e9aa6ab351fdc4d4c59d3421ea244f17a (patch)
tree5765e0d4e0651fa8aa4b09995b67db3939944832
parentb9445bb6dfbc8cbdabcfe88a6fc55e5855cd95ac (diff)
Added file name option for stdin pastes (-n <file name>)v1.1.4
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--fb.13
-rw-r--r--fb.in10
2 files changed, 10 insertions, 3 deletions
diff --git a/fb.1 b/fb.1
index cda5e16..26077d5 100644
--- a/fb.1
+++ b/fb.1
@@ -69,6 +69,9 @@ will try to extract the ID.
Change the extension used for highlighting. You can also do this if you
have already uploaded the file by appending the extension to the URL.
http://paste.xinu.at/<ID>/bash will change the syntax highlighting to bash.
+.It Fl n Ar file name
+Use the specified file name for the upload when pasting from stdin. Defaults
+to "stdin"
.It Fl g
Download the IDs and output on stdout. Please take care when using this, as
binary data may cause unexpected results when being output directly to a
diff --git a/fb.in b/fb.in
index aa52c99..3ab25db 100644
--- a/fb.in
+++ b/fb.in
@@ -40,6 +40,7 @@ fi
version="@VERSION@"
delete=
extension=""
+filename="stdin"
get=
tar=
compress=0
@@ -228,6 +229,8 @@ usage: [cat |] `basename "$0"` [switches] [options] [<file(s)|ID(s)|folder(s)>]
Options:
-e <extension> extension for default highlighting (e.g. "diff")
+ -n <file name> file name to use for upload when reading from stdin
+ Defaults to "stdin"
-t upload a tar file containing all files (and directories)
-c compress the file being uploaded with gz or xz if used 2 times
When used in conjunction with -g this decompresses the download
@@ -240,9 +243,10 @@ if ! type getopts >/dev/null 2>&1; then
exit 1
fi
-while getopts "e:gdhHtcvD" option; do
+while getopts "e:n:gdhHtcvD" option; do
case $option in
e) extension="$OPTARG";;
+ n) filename="$OPTARG";;
g) get=1;;
c) compress=`expr $compress + 1`;;
t) tar=1;;
@@ -293,8 +297,8 @@ elif [ $# -eq 0 ]; then
printf "%s\n" "Error: -t is not supported when operating on stdin" >&2
exit 1
fi
- read_stdin "$tmpdir/stdin"
- do_upload "$tmpdir/stdin" || exitcode=1
+ read_stdin "$tmpdir/$filename"
+ do_upload "$tmpdir/$filename" || exitcode=1
else
if [ "$tar" ]; then
have_url=